use of org.hibernate.orm.test.envers.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class TotalAuditParentsTest method testCompleteAuditParents.
@Test
public void testCompleteAuditParents() {
// expectedBaby.notAudited shall be null, because it is not audited.
BabyCompleteEntity expectedBaby = new BabyCompleteEntity(babyCompleteId, "grandparent 1", null, "parent 1", "child 1", new StrIntTestEntity("data 1", 1, siteCompleteId), "baby 1");
BabyCompleteEntity baby = getAuditReader().find(BabyCompleteEntity.class, babyCompleteId, 1);
Assert.assertEquals(expectedBaby, baby);
Assert.assertEquals(expectedBaby.getRelation().getId(), baby.getRelation().getId());
}
use of org.hibernate.orm.test.envers.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class SingleAuditParentsTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1
em.getTransaction().begin();
StrIntTestEntity siteSingle = new StrIntTestEntity("data 1", 1);
em.persist(siteSingle);
em.persist(new ChildSingleParentEntity(childSingleId, "grandparent 1", "notAudited 1", "parent 1", "child 1", siteSingle));
em.getTransaction().commit();
siteSingleId = siteSingle.getId();
em.close();
}
use of org.hibernate.orm.test.envers.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class RevisionConstraintQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
StrIntTestEntity site2 = new StrIntTestEntity("b", 15);
em.persist(site1);
em.persist(site2);
id1 = site1.getId();
Integer id2 = site2.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setStr1("d");
site2.setNumber(20);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setNumber(1);
site2.setStr1("z");
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
site1 = em.find(StrIntTestEntity.class, id1);
site2 = em.find(StrIntTestEntity.class, id2);
site1.setNumber(5);
site2.setStr1("a");
em.getTransaction().commit();
}
use of org.hibernate.orm.test.envers.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class RevisionConstraintQuery method testRevisionTypeEqQuery.
@Test
public void testRevisionTypeEqQuery() {
// The query shouldn't be ordered as always, otherwise - we get an exception.
List results = getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, true, true).add(AuditEntity.id().eq(id1)).add(AuditEntity.revisionType().eq(RevisionType.MOD)).getResultList();
Assert.assertEquals(3, results.size());
Assert.assertEquals(new StrIntTestEntity("d", 10, id1), results.get(0));
Assert.assertEquals(new StrIntTestEntity("d", 1, id1), results.get(1));
Assert.assertEquals(new StrIntTestEntity("d", 5, id1), results.get(2));
}
use of org.hibernate.orm.test.envers.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class StoreDeletedData method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1
em.getTransaction().begin();
StrIntTestEntity site1 = new StrIntTestEntity("a", 10);
em.persist(site1);
id1 = site1.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
em.remove(site1);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
StrIntTestEntity site2 = new StrIntTestEntity("b", 20);
em.persist(site2);
id2 = site2.getId();
StrIntTestEntity site3 = new StrIntTestEntity("c", 30);
em.persist(site3);
id3 = site3.getId();
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
em.remove(site2);
em.remove(site3);
em.getTransaction().commit();
em.close();
}
Aggregations