For Programmers: Free Programming Magazines  


Home > Archive > Java Beans > September 2004 > EJB CMP relationship and creating subordinate instances









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author EJB CMP relationship and creating subordinate instances
davout

2004-09-08, 9:01 am

I'm a little 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?




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com