em.getTransaction().rollback();
}
public void testDetachingDetachedEntityIsIgnored() {
em.getTransaction().begin();
DMCustomer pc = em.find(DMCustomer.class, root.getId());
List<DMCustomerInventory> inventories = pc.getCustomerInventories();
em.detach(pc);
DMCustomer detached = pc;
assertDetached(detached);
for (DMCustomerInventory inventory : inventories) {
assertDetached(inventory);
}
List<DMCustomerInventory> newInventories =
new ArrayList<DMCustomerInventory>();
newInventories.addAll(inventories);
DMCustomerInventory newInventory = new DMCustomerInventory();
newInventory.setCustomer(detached);
newInventories.add(newInventory);
detached.setCustomerInventories(newInventories);
em.persist(newInventory);
assertNotDetached(newInventory);
em.detach(detached);
assertDetached(detached);