I just read something on Sun's website that mentioned that the EJB 3.0 spec dropped support for CMR.
I'm looking into using EJB, but I want to know for sure what this statement means.
If I have two entity beans, Order and LineItem and my Order object has a List of LineItem objects, how will the elimination of CMR affect this relationship?
Joined: Oct 05, 2006
Paul- What this means is EJB 3 no longer maintains the relationship field at the other end of the relationship when one end is updated. For instance, in a 1:* relationship, if you insert into the collection end, the single-value end doesn't get updated automatically on the entity, and vice-versa. In EJB 2.x, the relationship field on the other end would automatically get wired up for you, which was convenient but incurred a huge overhead for the persistence manager. You can emulate the EJB 2.x behavior by modifying your entity code (or using a code generator to build your entities).
A common pattern is to define add/remove methods to accompany the Collection field, and modify the set method on the single-value end. In both cases, the idea is to update the field at the other end of the relationship.
The bottom line is relationships between JPA entities (successors to entity beans) are still supported, but the automatic wiring feature in EJB 2.x CMR fields is no longer there.