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();
}
use of org.hibernate.envers.test.entities.IntTestEntity in project hibernate-orm by hibernate.
the class TransactionRollbackBehaviour method testAuditRecordsRollbackBehavior.
private void testAuditRecordsRollbackBehavior(boolean flush, Boolean autoClear) {
EntityManager entityManager = getEntityManager();
try {
if (autoClear != null) {
entityManager.unwrap(SessionImpl.class).setAutoClear(autoClear);
}
// persist and rollback
entityManager.getTransaction().begin();
IntTestEntity rollbackEntity = new IntTestEntity(30);
entityManager.persist(rollbackEntity);
if (flush) {
entityManager.flush();
}
Integer rollbackId = rollbackEntity.getId();
entityManager.getTransaction().rollback();
// persist and commit
entityManager.getTransaction().begin();
IntTestEntity commitEntity = new IntTestEntity(50);
entityManager.persist(commitEntity);
if (flush) {
entityManager.flush();
}
Integer commitId = commitEntity.getId();
entityManager.getTransaction().commit();
List<Number> revisionsForSavedClass = getAuditReader().getRevisions(IntTestEntity.class, commitId);
assertEquals("There should be one revision for inserted entity.", 1, revisionsForSavedClass.size());
List<Number> revisionsForRolledbackClass = getAuditReader().getRevisions(IntTestEntity.class, rollbackId);
assertEquals("There should be no revision for rolled back entity.", 0, revisionsForRolledbackClass.size());
} finally {
entityManager.close();
}
}
Aggregations