Player p1 = new Player("p21", t, 20);
players.add(p1);
Player p2 = new Player("p22", t, 30);
players.add(p2);
t.setPlayers(players);
Coach c = new Coach("c23", 10, t);
t.setCoach(c);
PersistenceManager pm = pmf.getPersistenceManager();
pm.currentTransaction().begin();
logger.log(BasicLevel.DEBUG, "make persistent the team " + t.toString());
pm.makePersistent(t);
pm.currentTransaction().commit();
try {
//detach the team t
Team copyOfT = (Team) pm.detachCopy(t);
Coach newCoach = new Coach("c33", 15, new Team("DummyTeam",null,null));
// update the reference while detached
copyOfT.setCoach(newCoach);
//print the team out
logger.log(BasicLevel.DEBUG, "Copy of team " + copyOfT.toString());
pm.currentTransaction().begin();