use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class SimpleQuery method testEntitiesPropertyLeQuery.
@Test
public void testEntitiesPropertyLeQuery() {
List ver1 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 1).add(AuditEntity.property("number").le(10)).getResultList();
List ver2 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 2).add(AuditEntity.property("number").le(10)).getResultList();
List ver3 = getAuditReader().createQuery().forEntitiesAtRevision(StrIntTestEntity.class, 3).add(AuditEntity.property("number").le(10)).getResultList();
assert new HashSet(ver1).equals(TestTools.makeSet(new StrIntTestEntity("a", 10, id1), new StrIntTestEntity("a", 10, id2), new StrIntTestEntity("b", 5, id3)));
assert new HashSet(ver2).equals(TestTools.makeSet(new StrIntTestEntity("aBc", 10, id1), new StrIntTestEntity("b", 5, id3)));
assert new HashSet(ver3).equals(TestTools.makeSet(new StrIntTestEntity("aBc", 10, id1), new StrIntTestEntity("a", 5, id3)));
}
use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class StoreDeletedData method testRevisionsPropertyEqQuery.
@Test
public void testRevisionsPropertyEqQuery() {
List revs_id1 = getAuditReader().createQuery().forRevisionsOfEntity(StrIntTestEntity.class, false, true).add(AuditEntity.id().eq(id1)).getResultList();
Assert.assertEquals(2, revs_id1.size());
Assert.assertEquals(new StrIntTestEntity("a", 10, id1), ((Object[]) revs_id1.get(0))[0]);
Assert.assertEquals(new StrIntTestEntity("a", 10, id1), ((Object[]) revs_id1.get(1))[0]);
}
use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class CustomTrackingEntitiesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste = new StrTestEntity("x");
StrIntTestEntity site = new StrIntTestEntity("y", 1);
em.persist(ste);
em.persist(site);
steId = ste.getId();
siteId = site.getId();
em.getTransaction().commit();
// Revision 2 - Modifying one entity
em.getTransaction().begin();
site = em.find(StrIntTestEntity.class, siteId);
site.setNumber(2);
em.getTransaction().commit();
// Revision 3 - Deleting both entities
em.getTransaction().begin();
ste = em.find(StrTestEntity.class, steId);
site = em.find(StrIntTestEntity.class, siteId);
em.remove(ste);
em.remove(site);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method testFindChangedEntitiesByRevisionTypeDEL.
@Test
public void testFindChangedEntitiesByRevisionTypeDEL() {
StrTestEntity ste = new StrTestEntity(null, steId);
StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(3, RevisionType.DEL), ste, site);
}
use of org.hibernate.envers.test.entities.StrIntTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste = new StrTestEntity("x");
StrIntTestEntity site = new StrIntTestEntity("y", 1);
em.persist(ste);
em.persist(site);
steId = ste.getId();
siteId = site.getId();
em.getTransaction().commit();
// Revision 2 - Modifying one entity
em.getTransaction().begin();
site = em.find(StrIntTestEntity.class, siteId);
site.setNumber(2);
em.getTransaction().commit();
// Revision 3 - Deleting both entities
em.getTransaction().begin();
ste = em.find(StrTestEntity.class, steId);
site = em.find(StrIntTestEntity.class, siteId);
em.remove(ste);
em.remove(site);
em.getTransaction().commit();
}
Aggregations