use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class CustomDate method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
timestamp1 = System.currentTimeMillis();
// CustomDateRevEntity.dateTimestamp field maps to date type which on some RDBMSs gets
Thread.sleep(1100);
// truncated to seconds (for example MySQL 5.1).
// 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();
// CustomDateRevEntity.dateTimestamp field maps to date type which on some RDBMSs gets
Thread.sleep(1100);
// truncated to seconds (for example MySQL 5.1).
// 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.Priority in project hibernate-orm by hibernate.
the class CustomNoListener method initData.
@Test
@Priority(10)
public void initData() throws InterruptedException {
EntityManager em = getEntityManager();
// Revision 1
em.getTransaction().begin();
StrTestEntity te = new StrTestEntity("x");
em.persist(te);
id = te.getId();
// Setting the data on the revision entity
CustomDataRevEntity custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
custom.setData("data1");
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
te = em.find(StrTestEntity.class, id);
te.setStr("y");
// Setting the data on the revision entity
custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
custom.setData("data2");
em.getTransaction().commit();
// Revision 3 - no changes, but rev entity should be persisted
em.getTransaction().begin();
// Setting the data on the revision entity
custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, true);
custom.setData("data3");
em.getTransaction().commit();
// No changes, rev entity won't be persisted
em.getTransaction().begin();
// Setting the data on the revision entity
custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
custom.setData("data4");
em.getTransaction().commit();
// Revision 4
em.getTransaction().begin();
te = em.find(StrTestEntity.class, id);
te.setStr("z");
// Setting the data on the revision entity
custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
custom.setData("data5");
custom = getAuditReader().getCurrentRevision(CustomDataRevEntity.class, false);
custom.setData("data5bis");
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority in project hibernate-orm by hibernate.
the class NullPropertyQuery method initData.
@Test
@Priority(10)
public void initData() {
// Revision 1
EntityManager em = getEntityManager();
em.getTransaction().begin();
StrIntTestEntity nullSite = new StrIntTestEntity(null, 1);
StrIntTestEntity notNullSite = new StrIntTestEntity("data", 2);
em.persist(nullSite);
em.persist(notNullSite);
idSimplePropertyNull = nullSite.getId();
idSimplePropertyNotNull = notNullSite.getId();
em.getTransaction().commit();
// Revision 2
em.getTransaction().begin();
SetRefIngEmbIdEntity nullParentSrieie = new SetRefIngEmbIdEntity(idMulticolumnReferenceToParentNull, "data", null);
em.persist(nullParentSrieie);
em.getTransaction().commit();
// Revision 3
em.getTransaction().begin();
CollectionRefEdEntity parent = new CollectionRefEdEntity(idParent, "data");
CollectionRefIngEntity notNullParentCrie = new CollectionRefIngEntity(idReferenceToParentNotNull, "data", parent);
em.persist(parent);
em.persist(notNullParentCrie);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.Priority 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.Priority 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();
}
Aggregations