File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about Container Managed Relationship

 
parra matta
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
parra matta
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Regards,
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ever looked at a deployment descriptor?
 
parra matta
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. But the DD does not say the LineItems link to Order by order id.
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the link is implicitly by primary key
 
parra matta
Ranch Hand
Posts: 40
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic