use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class HasChangedIdMapKey method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
IdMapKeyEntity imke = new IdMapKeyEntity();
// Revision 1 (intialy 1 mapping)
em.getTransaction().begin();
StrTestEntity ste1 = new StrTestEntity("x");
StrTestEntity ste2 = new StrTestEntity("y");
em.persist(ste1);
em.persist(ste2);
imke.getIdmap().put(ste1.getId(), ste1);
em.persist(imke);
em.getTransaction().commit();
// Revision 2 (sse1: adding 1 mapping)
em.getTransaction().begin();
ste2 = em.find(StrTestEntity.class, ste2.getId());
imke = em.find(IdMapKeyEntity.class, imke.getId());
imke.getIdmap().put(ste2.getId(), ste2);
em.getTransaction().commit();
//
imke_id = imke.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class HasChangedManyToOneInComponent method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity ste1 = new StrTestEntity();
ste1.setStr("str1");
StrTestEntity ste2 = new StrTestEntity();
ste2.setStr("str2");
em.persist(ste1);
em.persist(ste2);
em.getTransaction().commit();
// Revision 2
em = getEntityManager();
em.getTransaction().begin();
ManyToOneComponentTestEntity mtocte1 = new ManyToOneComponentTestEntity(new ManyToOneComponent(ste1, "data1"));
em.persist(mtocte1);
em.getTransaction().commit();
// Revision 3
em = getEntityManager();
em.getTransaction().begin();
mtocte1 = em.find(ManyToOneComponentTestEntity.class, mtocte1.getId());
mtocte1.getComp1().setEntity(ste2);
em.getTransaction().commit();
mtocte_id1 = mtocte1.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class OneToManyUnidirectionalNaming method initData.
@Test
@Priority(10)
public void initData() {
DetachedNamingTestEntity uni1 = new DetachedNamingTestEntity(1, "data1");
StrTestEntity str1 = new StrTestEntity("str1");
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
uni1.setCollection(new HashSet<StrTestEntity>());
em.persist(uni1);
em.persist(str1);
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
uni1 = em.find(DetachedNamingTestEntity.class, uni1.getId());
str1 = em.find(StrTestEntity.class, str1.getId());
uni1.getCollection().add(str1);
em.getTransaction().commit();
//
uni1_id = uni1.getId();
str1_id = str1.getId();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class OneToManyUnidirectionalNaming method testHistoryOfUniId1.
@Test
public void testHistoryOfUniId1() {
StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
DetachedNamingTestEntity rev1 = getAuditReader().find(DetachedNamingTestEntity.class, uni1_id, 1);
DetachedNamingTestEntity rev2 = getAuditReader().find(DetachedNamingTestEntity.class, uni1_id, 2);
assert rev1.getCollection().equals(TestTools.makeSet());
assert rev2.getCollection().equals(TestTools.makeSet(str1));
assert "data1".equals(rev1.getData());
assert "data1".equals(rev2.getData());
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class VersionsJoinTableNaming method testHistoryOfUniId1.
@Test
public void testHistoryOfUniId1() {
StrTestEntity str1 = getEntityManager().find(StrTestEntity.class, str1_id);
VersionsJoinTableTestEntity rev1 = getAuditReader().find(VersionsJoinTableTestEntity.class, uni1_id, 1);
VersionsJoinTableTestEntity rev2 = getAuditReader().find(VersionsJoinTableTestEntity.class, uni1_id, 2);
assert rev1.getCollection().equals(TestTools.makeSet());
assert rev2.getCollection().equals(TestTools.makeSet(str1));
assert "data1".equals(rev1.getData());
assert "data1".equals(rev2.getData());
}
Aggregations