EJB CMP relationship and creating subordinate instances

D

davout

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top