use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class CustomPropertyAccess method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
timestamp1 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity te = new StrTestEntity("x");
em.persist(te);
id = te.getId();
em.getTransaction().commit();
timestamp2 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 2
em.getTransaction().begin();
te = em.find(StrTestEntity.class, id);
te.setStr("y");
em.getTransaction().commit();
timestamp3 = System.currentTimeMillis();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DifferentDBSchemaTest method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity ste = new StrTestEntity("x");
em.persist(ste);
steId = ste.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
ste = em.find(StrTestEntity.class, steId);
ste.setStr("y");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class ExceptionListener method testTransactionRollback.
@Test(expected = RuntimeException.class)
public void testTransactionRollback() throws InterruptedException {
// Trying to persist an entity - however the listener should throw an exception, so the entity
// shouldn't be persisted
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity te = new StrTestEntity("x");
em.persist(te);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class Inherited method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
timestamp1 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrTestEntity te = new StrTestEntity("x");
em.persist(te);
id = te.getId();
em.getTransaction().commit();
timestamp2 = System.currentTimeMillis();
Thread.sleep(100);
// Revision 2
em.getTransaction().begin();
te = em.find(StrTestEntity.class, id);
te.setStr("y");
em.getTransaction().commit();
timestamp3 = System.currentTimeMillis();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class BasicJoinColumnSet method testHistoryOfColl1.
@Test
public void testHistoryOfColl1() {
EntityManager entityManager = getEntityManager();
entityManager.getTransaction().begin();
StrTestEntity str1 = entityManager.find(StrTestEntity.class, str1_id);
StrTestEntity str2 = entityManager.find(StrTestEntity.class, str2_id);
entityManager.getTransaction().commit();
SetJoinColumnRefCollEntity rev1 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 1);
SetJoinColumnRefCollEntity rev2 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 2);
SetJoinColumnRefCollEntity rev3 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 3);
SetJoinColumnRefCollEntity rev4 = getAuditReader().find(SetJoinColumnRefCollEntity.class, coll1_id, 4);
assert rev1.getCollection().equals(TestTools.makeSet(str1));
assert rev2.getCollection().equals(TestTools.makeSet(str1, str2));
assert rev3.getCollection().equals(TestTools.makeSet(str2));
assert rev4.getCollection().equals(TestTools.makeSet());
assert "coll1".equals(rev1.getData());
assert "coll1".equals(rev2.getData());
assert "coll1".equals(rev3.getData());
assert "coll1".equals(rev4.getData());
}
Aggregations