Value Object relationship VS Entity Bean relationship...!
1 posts in topic
Flat View  Flat View

Posted By:   Anonymous
Posted On:   Sunday, June 16, 2002 08:11 PM

Where to define the relationship? In Value Objects or in Entity Beans.

For example, Order and Order Lines, there should be a composition relationship b/w Order Value Object and OrderLine Value Object.


Order Entity Bean can have a method "Collection getOrderLines()". In this way there is no relationship in Value Object and our VO are fine grained objects not course grained

Please suggest,

Re: Value Object relationship VS Entity Bean relationship...!

Posted By:   Nick_Maiorano  
Posted On:   Monday, June 17, 2002 06:24 PM


There are, in fact, even more options in designing this than those outlined in your post.

For example, you can employ an entity bean facade pattern in which a stateless session bean is aware of the relationship. You would create a method named getOrderLines(String orderId) which would return a collection of value objects. Employing this pattern is good because it abstracts all the knowledge of how multiple entity beans relate to each other. Spreading this knowledge accross the application is not desirable.

You can also implement the order/order line relationship as a single BMP. The clients would view these 2 tables as one. Outside of using raw JDBC, this would give you the best performance since your SQL joins would be done by the database as opposed to the application. This could be used with the facade as descibed in the previous paragraph.

As far as coarsed-grained vs fine-grained, there are no hard and fast rules. Having a coarsed-grained VO is good if you happen to need most of the data you are fetching but bad if you just need a single field. One thing is for sure though, keep your session bean methods coarsed-grained and pass around VO to your clients - not the entity beans themselves.

Hope this helps.
About | Sitemap | Contact