aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes CMR gone in EJB 3.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMR gone in EJB 3.0" Watch "CMR gone in EJB 3.0" New topic
Author

CMR gone in EJB 3.0

Paul Eggerling-Boeck
Greenhorn

Joined: Oct 05, 2006
Posts: 2
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?

Thanks!

Paul
Jon Wetherbee
author
Ranch Hand

Joined: Oct 05, 2006
Posts: 33
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.

Regards,
Jon

Beginning EJB 3 Application Development: From Novice to Professional
Paul Eggerling-Boeck
Greenhorn

Joined: Oct 05, 2006
Posts: 2
Thanks Jon. That sounds pretty much like what I'm used to doing in a Hibernate environment.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Originally posted by Paul Eggerling-Boeck:
Thanks Jon. That sounds pretty much like what I'm used to doing in a Hibernate environment.



"pretty much"? actually more "exactly" like.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: CMR gone in EJB 3.0