coll1_id = new EmbId(5, 6);
EmbIdTestEntity str1 = new EmbIdTestEntity(str1_id, "str1");
EmbIdTestEntity str2 = new EmbIdTestEntity(str2_id, "str2");
SetRefCollEntityEmbId coll1 = new SetRefCollEntityEmbId(coll1_id, "coll1");
// Revision 1
em.getTransaction().begin();
em.persist(str1);
em.persist(str2);
coll1.setCollection(new HashSet<EmbIdTestEntity>());
coll1.getCollection().add(str1);
em.persist(coll1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
str2 = em.find(EmbIdTestEntity.class, str2.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().add(str2);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
str1 = em.find(EmbIdTestEntity.class, str1.getId());
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().remove(str1);
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
coll1 = em.find(SetRefCollEntityEmbId.class, coll1.getId());
coll1.getCollection().clear();
em.getTransaction().commit();
}