persisting dependant objects in Entity Beans


EJB design: persisting dependant objects in Entity Beans

  1. persisting dependant objects in Entity Beans (5 messages)

    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.

    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.

  2. 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.

  3. Brian,

      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".

  4. 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, 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 ?
  5. hi

    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.

  6. Brian ,

    you may also find Keeping Track of Entity Data Changes Between Loads and Stores pattern useful on top of other resources.