Search in sources :

Example 56 with StrTestEntity

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);
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Example 57 with StrTestEntity

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();
}
Also used : StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) ListOwnedEntity(org.hibernate.envers.test.entities.manytomany.ListOwnedEntity) ListOwningEntity(org.hibernate.envers.test.entities.manytomany.ListOwningEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 58 with StrTestEntity

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();
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 59 with StrTestEntity

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);
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) Test(org.junit.Test)

Example 60 with StrTestEntity

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();
}
Also used : StrIntTestEntity(org.hibernate.envers.test.entities.StrIntTestEntity) StrTestEntity(org.hibernate.envers.test.entities.StrTestEntity) EntityManager(javax.persistence.EntityManager) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Aggregations

StrTestEntity (org.hibernate.envers.test.entities.StrTestEntity)103 Test (org.junit.Test)99 EntityManager (javax.persistence.EntityManager)51 Priority (org.hibernate.envers.test.Priority)48 Session (org.hibernate.Session)8 StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)8 TestForIssue (org.hibernate.testing.TestForIssue)5 ListRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.ListRefCollEntity)4 SetRefCollEntity (org.hibernate.envers.test.entities.onetomany.detached.SetRefCollEntity)4 ManyToOneComponent (org.hibernate.envers.test.entities.components.relations.ManyToOneComponent)3 ManyToOneComponentTestEntity (org.hibernate.envers.test.entities.components.relations.ManyToOneComponentTestEntity)3 OneToManyComponent (org.hibernate.envers.test.entities.components.relations.OneToManyComponent)3 OneToManyComponentTestEntity (org.hibernate.envers.test.entities.components.relations.OneToManyComponentTestEntity)3 SortedSetEntity (org.hibernate.envers.test.entities.manytomany.SortedSetEntity)3 ListUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.ListUniEntity)3 SetUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.SetUniEntity)3 List (java.util.List)2 RevisionType (org.hibernate.envers.RevisionType)2 JoinTableEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.JoinTableEntity)2 MapUniEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.MapUniEntity)2