EntityManager em = emf.createEntityManager();
try {
// Create simple bi-di graph
ShipPackage2 p = new ShipPackage2();
Label2 l = new Label2(p);
p.setLabel2(l);
// Persist
em.getTransaction().begin();
em.persist(p);
em.getTransaction().commit();
// Detach
em.clear();
assertFalse(em.contains(l));
assertFalse(em.contains(p));
assertFalse(em.contains(l.getPackage2()));
assertFalse(em.contains(p.getLabel2()));
em.getTransaction().begin();
ShipPackage2 mergedPackage = em.merge(p);