-
1. Re: How are you supposed to add a child entity in a CMP CMR
aagmon Sep 16, 2004 4:27 AM (in response to davout)the Entitiy's home is creating instances of the Entitiy's Remote Interface
Collection entities = Ent1Home.findBySomething(); Iterator t = entities.iterator() while(t.hasNext){ Ent1Remote ent1 = (Ent1Remote)t.next; ent1.doSomething() }
-
2. Re: How are you supposed to add a child entity in a CMP CMR
davout Sep 16, 2004 6:49 AM (in response to davout)I'm not sure if I understand your point. The CMR based Entity1 collection of Entity2 instances doesn't appear to be updated after an Entity2 instance is separately created.
-
3. Re: How are you supposed to add a child entity in a CMP CMR
aagmon Sep 16, 2004 12:21 PM (in response to davout)ok,
lets say we have a team and player entities.
use a session bean that preforms a lookup for team's and player's home.
you can add to the session bean:
after you create a new player
public void addPlayer(String player_name ,String team){
Player player = PlayerHome.create(player_name);
Team team = home.findByName(team);
team.add(player);
}
while in the Team entity the add() will be implemented as:
public add(Player player){
Collection players = getPlayers();
players.add(player);
} -
4. Re: How are you supposed to add a child entity in a CMP CMR
davout Sep 16, 2004 3:58 PM (in response to davout)Many thanks for the response...
I'd sought of guessed the answer might be something like you suggested.
However, this raises another problem. What if 'Entity2' has a property called 'Color' and the color entity owns a collection of Entity2 objects, like...
class Entity1Bean {
ejbCreate(....)
Collection getEntity2List() // returns collection of 'Entity2'
}
class Entity2Bean {
ejbCreate(....)
Color getColor // points at related color object
}
class ColorBean {
Collection getEntity2List() // returns collection of 'Entity2' objects
// that share the same color
}
In this case where 'Entity2' has two different entities in which it appears as a collection entry, where would you call the 'add'. Or do you have to call both?