My database schema has a customer and address table. the address is dependent on the customer so i think i need to make the address a dependent object of the customer entity bean. Firstly is this a correct assumption.
- Posted by: Brian O'Neill
- Posted on: January 19 2001 08:26 EST
secondly if this is correct, how do i persist the customers address details.
I'm pretty new to this stuff so any help would be great.
- persisting dependant objects in Entity Beans by Saket Malhotra on January 19 2001 12:29 EST
- persisting dependant objects in Entity Beans by Floyd Marinescu on January 19 2001 12:49 EST
- persisting dependant objects in Entity Beans by somal sood on January 21 2001 23:46 EST
- persisting dependant objects in Entity Beans by Leo Shuster on January 22 2001 14:36 EST
The best way is to create a session bean which will call both customer and address entity beans. You also need to keep both the entity beans under same transaction.
Your assumption is correct. If you want to see how this is done and want a complete workable code example, see the article I wrote in the resources section called "Course Grained BMP beans with Dependent Value Objects".
How does the coarse grained entity bean with dependant value objects scheme work, if the dependant value object (DVO) itself contains another collection of dependant value objects.
In the example at http://www.theserverside.com/patterns/depbmp.jsp, if the job entry DVO was to itself contain a collection class (let's say that a job entry could contain a dependant list of "projects" that the applicant worked on during the job, where project is another DVO).
Would this scheme extend to arbitrary nested collections of dependant objects ?
I think ejb2.0 would tackel this problem more accurately and easily.
I have read in ejb 2.0 specification that dependent Objects( as here address dependent on Customer )are handled by specifing relationship in deployment descriptor.
you may also find Keeping Track of Entity Data Changes Between Loads and Stores pattern useful on top of other resources.