use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class Simple method testHistoryOfId1.
@Test
public void testHistoryOfId1() {
IntTestEntity ver1 = new IntTestEntity(10, id1);
IntTestEntity ver2 = new IntTestEntity(20, id1);
Assert.assertEquals(ver1, getAuditReader().find(IntTestEntity.class, id1, 1));
Assert.assertEquals(ver2, getAuditReader().find(IntTestEntity.class, id1, 2));
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class QueryCache method testCacheFindAfterEntitiesAtRevisionQuery.
@Test
public void testCacheFindAfterEntitiesAtRevisionQuery() {
IntTestEntity entFromQuery = (IntTestEntity) getAuditReader().createQuery().forEntitiesAtRevision(IntTestEntity.class, 1).getSingleResult();
IntTestEntity entFromFind = getAuditReader().find(IntTestEntity.class, id1, 1);
assert entFromFind == entFromQuery;
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class OrderByLimitQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
IntTestEntity ite1 = new IntTestEntity(12);
IntTestEntity ite2 = new IntTestEntity(5);
IntTestEntity ite3 = new IntTestEntity(8);
IntTestEntity ite4 = new IntTestEntity(1);
em.persist(ite1);
em.persist(ite2);
em.persist(ite3);
em.persist(ite4);
id1 = ite1.getId();
id2 = ite2.getId();
id3 = ite3.getId();
id4 = ite4.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
IntTestEntity ite5 = new IntTestEntity(3);
em.persist(ite5);
id5 = ite5.getId();
ite1 = em.find(IntTestEntity.class, id1);
ite1.setNumber(0);
ite4 = em.find(IntTestEntity.class, id4);
ite4.setNumber(15);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class AggregateQuery method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1
em.getTransaction().begin();
IntTestEntity ite1 = new IntTestEntity(2);
IntTestEntity ite2 = new IntTestEntity(10);
em.persist(ite1);
em.persist(ite2);
Integer id1 = ite1.getId();
Integer id2 = ite2.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
IntTestEntity ite3 = new IntTestEntity(8);
UnusualIdNamingEntity uine1 = new UnusualIdNamingEntity("id1", "data1");
em.persist(uine1);
em.persist(ite3);
ite1 = em.find(IntTestEntity.class, id1);
ite1.setNumber(0);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
ite2 = em.find(IntTestEntity.class, id2);
ite2.setNumber(52);
em.getTransaction().commit();
em.close();
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class JtaTransaction method initData.
@Test
@Priority(10)
public void initData() throws Exception {
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
EntityManager em;
IntTestEntity ite;
try {
em = getEntityManager();
ite = new IntTestEntity(10);
em.persist(ite);
id1 = ite.getId();
} finally {
TestingJtaPlatformImpl.tryCommit();
}
em.close();
TestingJtaPlatformImpl.INSTANCE.getTransactionManager().begin();
try {
em = getEntityManager();
ite = em.find(IntTestEntity.class, id1);
ite.setNumber(20);
} finally {
TestingJtaPlatformImpl.tryCommit();
}
em.close();
}
Aggregations