Hola all.
I have the following problem.
I have bidirectional, one to many relation (Team and Players)
I have a session facade bean contains the following methods :
public Collection getTeamPlayers(String name) { Collection players = null; try { LocalTeam team = teamHome.findByPrimaryKey(name); players = team.getPlayers(); this.convertCollection(players); } catch (FinderException e) { System.err.println("Error in getTeamPlayers(): " + e.toString( )); } return players; } private Collection convertCollection(Collection col) { Iterator it = col.iterator(); Vector vec = new Vector(1); while (it.hasNext()) { PlayerDTO dto = this.extract((LocalPlayer)it.next()); vec.addElement(dto); } return vec; } private PlayerDTO extract(LocalPlayer player) { PlayerDTO dto = null; try { dto = new PlayerDTO(player.getNum(), player.getName()); } catch (Exception e) { System.err.println("Error in extract( ): " + e.toString( )); } return dto; }
I found it.
take a look at getTeamPlayers( ) and you will know !