Re: Value Object relationship VS Entity Bean relationship...!
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.