@Test(enabled = true)
public void createData() {
EntityManager em = getEntityManager();
ListJoinColumnBidirectionalRefEdEntity ed1 = new ListJoinColumnBidirectionalRefEdEntity("ed1", null);
ListJoinColumnBidirectionalRefEdEntity ed2 = new ListJoinColumnBidirectionalRefEdEntity("ed2", null);
ListJoinColumnBidirectionalRefIngEntity ing1 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed1);
ListJoinColumnBidirectionalRefIngEntity ing2 = new ListJoinColumnBidirectionalRefIngEntity("coll1", ed2);
// Revision 1 (ing1: ed1, ing2: ed2)
em.getTransaction().begin();
em.persist(ed1);
em.persist(ed2);
em.persist(ing1);
em.persist(ing2);
em.getTransaction().commit();
// Revision 2 (ing1: ed1, ed2)
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
ing2.getReferences().remove(ed2);
ing1.getReferences().add(ed2);
em.getTransaction().commit();
em.clear();
// No revision - no changes
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed2 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed2.getId());
ed2.setOwner(ing2);
em.getTransaction().commit();
em.clear();
// Revision 3 (ing1: ed1, ed2)
em.getTransaction().begin();
ed1 = em.find(ListJoinColumnBidirectionalRefEdEntity.class, ed1.getId());
ed1.setData("ed1 bis");
// Shouldn't get written
ed1.setOwner(ing2);
em.getTransaction().commit();
em.clear();
// Revision 4 (ing2: ed1, ed2)
em.getTransaction().begin();
ing1 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing1.getId());
ing2 = em.find(ListJoinColumnBidirectionalRefIngEntity.class, ing2.getId());
ing1.getReferences().clear();
ing2.getReferences().add(ed1);
ing2.getReferences().add(ed2);
em.getTransaction().commit();
em.clear();
//
ing1_id = ing1.getId();
ing2_id = ing2.getId();
ed1_id = ed1.getId();
ed2_id = ed2.getId();
}