use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class LongRevNumber method testHistoryOfId1.
@Test
public void testHistoryOfId1() {
StrTestEntity ver1 = new StrTestEntity("x", id);
StrTestEntity ver2 = new StrTestEntity("y", id);
assert getAuditReader().find(StrTestEntity.class, id, 1l).equals(ver1);
assert getAuditReader().find(StrTestEntity.class, id, 2l).equals(ver2);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class AbstractRevisionEntityRemovalTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - simple entity
em.getTransaction().begin();
em.persist(new StrTestEntity("data"));
em.getTransaction().commit();
// Revision 2 - many-to-many relation
em.getTransaction().begin();
ListOwnedEntity owned = new ListOwnedEntity(1, "data");
ListOwningEntity owning = new ListOwningEntity(1, "data");
owned.setReferencing(new ArrayList<ListOwningEntity>());
owning.setReferences(new ArrayList<ListOwnedEntity>());
owned.getReferencing().add(owning);
owning.getReferences().add(owned);
em.persist(owned);
em.persist(owning);
em.getTransaction().commit();
em.getTransaction().begin();
Assert.assertEquals(1, countRecords(em, "STR_TEST_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwned_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwning_AUD"));
Assert.assertEquals(1, countRecords(em, "ListOwning_ListOwned_AUD"));
em.getTransaction().commit();
em.close();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class CustomTrackingEntitiesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste = new StrTestEntity("x");
StrIntTestEntity site = new StrIntTestEntity("y", 1);
em.persist(ste);
em.persist(site);
steId = ste.getId();
siteId = site.getId();
em.getTransaction().commit();
// Revision 2 - Modifying one entity
em.getTransaction().begin();
site = em.find(StrIntTestEntity.class, siteId);
site.setNumber(2);
em.getTransaction().commit();
// Revision 3 - Deleting both entities
em.getTransaction().begin();
ste = em.find(StrTestEntity.class, steId);
site = em.find(StrIntTestEntity.class, siteId);
em.remove(ste);
em.remove(site);
em.getTransaction().commit();
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method testFindChangedEntitiesByRevisionTypeDEL.
@Test
public void testFindChangedEntitiesByRevisionTypeDEL() {
StrTestEntity ste = new StrTestEntity(null, steId);
StrIntTestEntity site = new StrIntTestEntity(null, null, siteId);
assert TestTools.checkCollection(getCrossTypeRevisionChangesReader().findEntities(3, RevisionType.DEL), ste, site);
}
use of org.hibernate.envers.test.entities.StrTestEntity in project hibernate-orm by hibernate.
the class DefaultTrackingEntitiesTest method initData.
@Test
@Priority(10)
public void initData() {
EntityManager em = getEntityManager();
// Revision 1 - Adding two entities
em.getTransaction().begin();
StrTestEntity ste = new StrTestEntity("x");
StrIntTestEntity site = new StrIntTestEntity("y", 1);
em.persist(ste);
em.persist(site);
steId = ste.getId();
siteId = site.getId();
em.getTransaction().commit();
// Revision 2 - Modifying one entity
em.getTransaction().begin();
site = em.find(StrIntTestEntity.class, siteId);
site.setNumber(2);
em.getTransaction().commit();
// Revision 3 - Deleting both entities
em.getTransaction().begin();
ste = em.find(StrTestEntity.class, steId);
site = em.find(StrIntTestEntity.class, siteId);
em.remove(ste);
em.remove(site);
em.getTransaction().commit();
}
Aggregations