Hey all.
assume we have two CMP beans TeamBean, PlayerBean
the relationship is one to many and bidirectional.
TeamBean has the following CMP fields:
name, city
TeamBean has setter and getter methods for these fields.
the database schema for TeamBean is :
NAME, CITY
PlayerBean has the following CMP fields :
id, email
PlayerBean has setter and getter methods for these fields.
the database schema for PlayerBean is :
ID, EMAIL, TEAM (TEAM is FK)
I have the following code (in a facade bean):
public void addPlayer(id, name, String team) { LocalPlayer lp = playerHome.create(id, name); LocalTeam lt = teamHome.findByPrimayKey(team); lp.setTeamLocal(lt); }
new PlayerDO(local.getID( ), local.getEmail( ), local.getTeam( ));
new PlayerDO(local.getID( ), local.getEmail( ), local.getTeamLocal( ).getName( ));