use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class OrderByLimitQuery method testEntitiesOrderLimitByQueryRev2.
@Test
public void testEntitiesOrderLimitByQueryRev2() {
List res_0_to_1 = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 2).addOrder(AuditEntity.property("number").desc()).setFirstResult(0).setMaxResults(2).getResultList();
List res_2_to_3 = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 2).addOrder(AuditEntity.property("number").desc()).setFirstResult(2).setMaxResults(2).getResultList();
List res_4 = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 2).addOrder(AuditEntity.property("number").desc()).setFirstResult(4).setMaxResults(2).getResultList();
assert Arrays.asList(new IntTestEntity(15, id4), new IntTestEntity(8, id3)).equals(res_0_to_1);
assert Arrays.asList(new IntTestEntity(5, id2), new IntTestEntity(3, id5)).equals(res_2_to_3);
assert Arrays.asList(new IntTestEntity(0, id1)).equals(res_4);
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class OrderByLimitQuery method testEntitiesOrderLimitByQueryRev1.
@Test
public void testEntitiesOrderLimitByQueryRev1() {
List res_0_to_1 = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 1).addOrder(AuditEntity.property("number").desc()).setFirstResult(0).setMaxResults(2).getResultList();
List res_2_to_3 = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 1).addOrder(AuditEntity.property("number").desc()).setFirstResult(2).setMaxResults(2).getResultList();
List res_empty = getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 1).addOrder(AuditEntity.property("number").desc()).setFirstResult(4).setMaxResults(2).getResultList();
assert Arrays.asList(new IntTestEntity(12, id1), new IntTestEntity(8, id3)).equals(res_0_to_1);
assert Arrays.asList(new IntTestEntity(5, id2), new IntTestEntity(1, id4)).equals(res_2_to_3);
assert Arrays.asList().equals(res_empty);
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class QueryCache method testCacheFindAfterRevisionsOfEntityQuery.
@Test
public void testCacheFindAfterRevisionsOfEntityQuery() {
List entsFromQuery = getAuditReader().createQuery().forRevisionsOfEntity(IntTestEntity.class, true, false).getResultList();
IntTestEntity entFromFindRev1 = getAuditReader().find(IntTestEntity.class, id1, 1);
IntTestEntity entFromFindRev2 = getAuditReader().find(IntTestEntity.class, id1, 2);
assert entFromFindRev1 == entsFromQuery.get(0);
assert entFromFindRev2 == entsFromQuery.get(1);
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class QueryCache method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
IntTestEntity ite = new IntTestEntity(10);
em.persist(ite);
id1 = ite.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ite = em.find(IntTestEntity.class, id1);
ite.setNumber(20);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class Simple method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
em.getTransaction().begin();
IntTestEntity ite = new IntTestEntity(10);
em.persist(ite);
id1 = ite.getId();
em.getTransaction().commit();
em.getTransaction().begin();
ite = em.find(IntTestEntity.class, id1);
ite.setNumber(20);
em.getTransaction().commit();
}
Aggregations