public void testCascadeMergeDetachState() {
EntityManager em = emf.createEntityManager();
try {
// Create simple bi-di graph
ShipPackage p = new ShipPackage();
Label l = new Label(p);
p.setLabel(l);
// Persist
em.getTransaction().begin();
em.persist(l);
em.getTransaction().commit();
// Detach
em.clear();
assertFalse(em.contains(l));
assertFalse(em.contains(p));
assertFalse(em.contains(l.getPackage()));
assertFalse(em.contains(p.getLabel()));
em.getTransaction().begin();
Label mergedLabel = em.merge(l);
assertFalse(mergedLabel == l);