CSC/ECE 517 Fall 2007/wiki2 2 22
Object-relational mapping. Ruby's ActiveRecord is one attempt to allow an object-oriented program to use a relational database. The Crossing Chasms pattern is another. Look up several approaches to mapping relational databases to o-o programs, include hyperlinks to all of them, and explain how they differ. Report on the strengths of various approaches (making sure to credit the authors for their insights).
Introduction
Object Relational Mapping pattern is defined as - An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
ORM Implementations
Ruby's Active Record
Major features of Active Records
- Automated mapping between classes and tables, attributes and columns.
- Associations between objects controlled by simple meta-programming macros.
- Aggregations of value objects controlled by simple meta-programming macros.
- Validation rules that can differ for new or existing objects.
- Acts that can make records work as lists or trees
- Callbacks as methods or queues on the entire lifecycle (instantiation, saving, destroying, validating, etc).
- Observers for the entire lifecycle
- Inheritance hierarchies
- Transaction support on both a database and object level.
- Reflections on columns, associations, and aggregations
- Direct manipulation (instead of service invocation like hibernate)
- Database abstraction through simple adapters (~100 lines) with a shared connector
- Logging support for Log4r and Logger
Crossing Chasms pattern
Hibernate
Hibernate supports key OO features
- Hibernate supports natural OO idiom; inheritance, polymorphism, composition and the Java collections framework
- It supports fine-grained object models - a rich variety of mappings for collections and dependent objects
- There is no extra code generation or bytecode processing steps in build procedure
- Hibernate is extremely performant, has a dual-layer cache architecture, and may be used in a cluster
- Hibernate addresses both sides of the problem; not only how to get objects into the database, but also how to get them out again
- Hibernate supports both long-lived persistence contexts, detach/reattach of objects, and takes care of optimistic locking automatically
- Hibernate implements the Java Persistence management API and object/relational mapping options (EJB 3.0), two members of the Hibernate team are active in the expert group