Monday, February 7, 2011

O/R mapping

http://www.agiledata.org/essays/mappingObjects.html

mapping Object to Relational databases
The easiest mapping you will ever have is a property mapping of a single attribute to a single column.

Shadow information is any data that objects need to maintain, above and beyond their normal domain data, to persist themselves. This typically includes primary key information

One type of shadow information that I have not discussed yet is a boolean flag to indicate whether an object currently exists in the database.
A common practice is for each class to implement an isPersistent boolean fla that is set to true when the data is read in from the database and set to false when the object is newly created. ( or isLocal() )

--
Shadow information doesn’t necessarily need to be implemented by the business objects, although your application will need to take care of it somehow. For example, with Enterprise JavaBeans (EJBs) you store primary key information outside of EJBs in primary key classes, the individual object references a corresponding primary key object. The Java Data Object (JDO) approach goes one step further and implement shadow information in the JDOs and not the business objects. (Do, DoImpl)

nts at an important part of the O/R impedance mismatch between object technology and relational technology. Classes implement both behavior and data whereas relational database tables just implement data.

No comments:

Post a Comment