EJB CMP relationship and creating subordinate instances

Discussion in 'Java' started by davout, Sep 8, 2004.

  1. davout

    davout Guest

    I'm a little confused about how a CMP entity bean that has 1-M relationship
    link to a subordinate entity should handle the creation new subordinate
    entity instances.

    For instance,...

    class Entity1Bean {
    ejbCreate(....)
    Collection getEntity2List() // returns collection of 'Entity2'
    }

    class Entity2Bean {
    ejbCreate(....)
    }

    At the moment I'm handling the creation of new Entity2 instances by....

    Entity2Home.create(....)

    However, when I then use 'Entity1Home.getEntity2List' to retrieve a list of
    linked sub entities the newly created Entity2 instance is not part of the
    list.

    I then tried adding.....

    aNewEntity1 = Entity2Home.create(....)
    Entity1Home.getEntity2List().add(aNewEntity1);

    .... and it still didn't work. What am I doing wrong?
    davout, Sep 8, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrea Sansottera

    no cmp field defined in cmp ejb

    Andrea Sansottera, Jul 16, 2004, in forum: Java
    Replies:
    0
    Views:
    377
    Andrea Sansottera
    Jul 16, 2004
  2. Tobias Merler
    Replies:
    1
    Views:
    3,105
    Sudsy
    Sep 8, 2004
  3. Guest
    Replies:
    0
    Views:
    389
    Guest
    Feb 2, 2007
  4. Raymond Schanks
    Replies:
    0
    Views:
    644
    Raymond Schanks
    Aug 3, 2010
  5. BlueFielder
    Replies:
    8
    Views:
    149
    BlueFielder
    Sep 8, 2013
Loading...

Share This Page