persisting dependant objects in Entity Beans

Discussions

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.

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

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

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

    <p>
    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).

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


    somal
  6. Brian ,

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

    Leo