Search in sources :

Example 6 with CollectionRefEdEntity

use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.

the class BasicCollection method testHistoryOfEdIng2.

@Test
public void testHistoryOfEdIng2() {
    CollectionRefEdEntity ed1 = getEntityManager().find(CollectionRefEdEntity.class, ed1_id);
    CollectionRefEdEntity ed2 = getEntityManager().find(CollectionRefEdEntity.class, ed2_id);
    CollectionRefIngEntity rev1 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 1);
    CollectionRefIngEntity rev2 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 2);
    CollectionRefIngEntity rev3 = getAuditReader().find(CollectionRefIngEntity.class, ing2_id, 3);
    assert rev1.getReference().equals(ed1);
    assert rev2.getReference().equals(ed1);
    assert rev3.getReference().equals(ed2);
}
Also used : CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test)

Example 7 with CollectionRefEdEntity

use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.

the class BasicCollection method testHistoryOfEdIng1.

@Test
public void testHistoryOfEdIng1() {
    CollectionRefEdEntity ed1 = getEntityManager().find(CollectionRefEdEntity.class, ed1_id);
    CollectionRefEdEntity ed2 = getEntityManager().find(CollectionRefEdEntity.class, ed2_id);
    CollectionRefIngEntity rev1 = getAuditReader().find(CollectionRefIngEntity.class, ing1_id, 1);
    CollectionRefIngEntity rev2 = getAuditReader().find(CollectionRefIngEntity.class, ing1_id, 2);
    CollectionRefIngEntity rev3 = getAuditReader().find(CollectionRefIngEntity.class, ing1_id, 3);
    assert rev1.getReference().equals(ed1);
    assert rev2.getReference().equals(ed2);
    assert rev3.getReference().equals(ed2);
}
Also used : CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test)

Example 8 with CollectionRefEdEntity

use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.

the class BasicCollection method testHistoryOfEdId1.

@Test
public void testHistoryOfEdId1() {
    CollectionRefIngEntity ing1 = getEntityManager().find(CollectionRefIngEntity.class, ing1_id);
    CollectionRefIngEntity ing2 = getEntityManager().find(CollectionRefIngEntity.class, ing2_id);
    CollectionRefEdEntity rev1 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 1);
    CollectionRefEdEntity rev2 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 2);
    CollectionRefEdEntity rev3 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 3);
    assert rev1.getReffering().containsAll(makeSet(ing1, ing2));
    assert rev1.getReffering().size() == 2;
    assert rev2.getReffering().containsAll(makeSet(ing2));
    assert rev2.getReffering().size() == 1;
    assert rev3.getReffering().containsAll(Collections.EMPTY_SET);
    assert rev3.getReffering().size() == 0;
}
Also used : CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test)

Example 9 with CollectionRefEdEntity

use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.

the class SerializingCollection method initData.

@Test
@Priority(10)
public void initData() {
    EntityManager em = getEntityManager();
    CollectionRefEdEntity ed1 = new CollectionRefEdEntity(1, "data_ed_1");
    CollectionRefIngEntity ing1 = new CollectionRefIngEntity(3, "data_ing_1", ed1);
    // Revision 1
    em.getTransaction().begin();
    em.persist(ed1);
    em.persist(ing1);
    em.getTransaction().commit();
    //
    ed1_id = ed1.getId();
    ing1_id = ing1.getId();
}
Also used : EntityManager(javax.persistence.EntityManager) CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test) Priority(org.hibernate.envers.test.Priority)

Example 10 with CollectionRefEdEntity

use of org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity in project hibernate-orm by hibernate.

the class SerializingCollection method testDetach.

@Test
public void testDetach() throws Exception {
    CollectionRefIngEntity ing1 = getEntityManager().find(CollectionRefIngEntity.class, ing1_id);
    CollectionRefEdEntity rev1 = getAuditReader().find(CollectionRefEdEntity.class, ed1_id, 1);
    // First forcing loading of the collection
    assert rev1.getReffering().size() == 1;
    // Now serializing and de-serializing the
    rev1 = serializeDeserialize(rev1);
    // And checking the colleciton again
    assert rev1.getReffering().contains(ing1);
    assert rev1.getReffering().size() == 1;
}
Also used : CollectionRefIngEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity) CollectionRefEdEntity(org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity) Test(org.junit.Test)

Aggregations

CollectionRefEdEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity)10 CollectionRefIngEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity)10 Test (org.junit.Test)10 EntityManager (javax.persistence.EntityManager)4 Priority (org.hibernate.envers.test.Priority)4 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 IntTestPrivSeqEntity (org.hibernate.envers.test.entities.IntTestPrivSeqEntity)1 StrIntTestEntity (org.hibernate.envers.test.entities.StrIntTestEntity)1 StrTestPrivSeqEntity (org.hibernate.envers.test.entities.StrTestPrivSeqEntity)1 UnversionedStrTestEntity (org.hibernate.envers.test.entities.UnversionedStrTestEntity)1 StringSetEntity (org.hibernate.envers.test.entities.collection.StringSetEntity)1 ListOwnedEntity (org.hibernate.envers.test.entities.manytomany.ListOwnedEntity)1 ListOwningEntity (org.hibernate.envers.test.entities.manytomany.ListOwningEntity)1 SetOwnedEntity (org.hibernate.envers.test.entities.manytomany.SetOwnedEntity)1 SetOwningEntity (org.hibernate.envers.test.entities.manytomany.SetOwningEntity)1 M2MIndexedListTargetNotAuditedEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.M2MIndexedListTargetNotAuditedEntity)1 SetRefEdEntity (org.hibernate.envers.test.entities.onetomany.SetRefEdEntity)1 SetRefIngEntity (org.hibernate.envers.test.entities.onetomany.SetRefIngEntity)1