Player p1 = new Player("p5", t, 20);
players.add(p1);
Player p2 = new Player("p6", t, 30);
players.add(p2);
t.setPlayers(players);
Coach c = new Coach("c3", 10, t);
t.setCoach(c);
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
pm.makePersistent(t);
pm.currentTransaction().commit();
//begin
pm.currentTransaction().begin();
//detach the team t
Team copyOfT = null;
try {
copyOfT = (Team) pm.detachCopy(t);
// modify the coach
t.setCoach(new Coach("c31", 10, t));
Iterator it = t.getPlayers().iterator();
//modify the players
while(it.hasNext()){
Player p = (Player) it.next();
p.setAge(99);