aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Question about Container Managed Relationship Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Question about Container Managed Relationship" Watch "Question about Container Managed Relationship" New topic
Author

Question about Container Managed Relationship

parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Hi,

Say we have two entity beans: Order and LineItem. The relationship defined in the DD is one to many. How does the container know which line item belongs to an order? Does it check the foreign key? I cannot find anywhere in the DD says the field order id in LineItem reference to the order id field in Order.

Thanks in advance.

Parra Matta
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
That's one of the things that's container dependent.
It might do a query on the LINEITEM table requesting every record with the correct orderId whenever a collection of lineitems is requested for example (in fact that's the most likely scenario).
Of it might keep an internal list of them for each order that's been loaded (less likely).
[ September 15, 2006: Message edited by: Jeroen T Wenting ]

42
parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Hi,

But how does the container know that the LineItem is linked to the Order by order id?

Regards,
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
ever looked at a deployment descriptor?
parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Yes. But the DD does not say the LineItems link to Order by order id.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
the link is implicitly by primary key
parra matta
Ranch Hand

Joined: Mar 23, 2006
Posts: 40
Does it mean that the LineItem must have a field named orderId, so the container can match it to the Order? What if the primary key of Order is a composite primary key? There is nowhere says that the two entity beans that have a relationship must have a field with same name so they can be linked.
 
Don't get me started about those stupid light bulbs.
 
subject: Question about Container Managed Relationship