use of org.hibernate.envers.test.entities.StrTestEntity 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.entities.StrTestEntity in project hibernate-orm by hibernate.
the class CustomNoListener method testHistoryOfId1.
@Test
public void testHistoryOfId1() {
StrTestEntity ver1 = new StrTestEntity("x", id);
StrTestEntity ver2 = new StrTestEntity("y", id);
StrTestEntity ver3 = new StrTestEntity("z", id);
assert getAuditReader().find(StrTestEntity.class, id, 1).equals(ver1);
assert getAuditReader().find(StrTestEntity.class, id, 2).equals(ver2);
assert getAuditReader().find(StrTestEntity.class, id, 3).equals(ver2);
assert getAuditReader().find(StrTestEntity.class, id, 4).equals(ver3);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class CustomPropertyAccess method testHistoryOfId1.
@Test
public void testHistoryOfId1() {
StrTestEntity ver1 = new StrTestEntity("x", id);
StrTestEntity ver2 = new StrTestEntity("y", id);
assert getAuditReader().find(StrTestEntity.class, id, 1).equals(ver1);
assert getAuditReader().find(StrTestEntity.class, id, 2).equals(ver2);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method testTrackDeletedEntities.
@Test
public void testTrackDeletedEntities() {
StrTestEntity ste = new StrTestEntity(null, steId);
StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(3), site, ste);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method testTrackDeletedEntitiesGroupByRevisionType.
@Test
public void testTrackDeletedEntitiesGroupByRevisionType() {
StrTestEntity ste = new StrTestEntity(null, steId);
StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
Map<RevisionType, List<Object>> result = getCrossTypeRevisionChangesReader().findEntitiesGroupByRevisionType(3);
assert TestTools.checkCollection(result.get(RevisionType.ADD));
assert TestTools.checkCollection(result.get(RevisionType.MOD));
assert TestTools.checkCollection(result.get(RevisionType.DEL), site, ste);
}
Aggregations