Search in sources :

Example 16 with SetOwnedEntity

use of org.hibernate.envers.test.entities.manytomany.SetOwnedEntity in project hibernate-orm by hibernate.

the class RemovedObjectQueryTest method testOwnedManyToManyDifferentRevisions.

@Test
public void testOwnedManyToManyDifferentRevisions() {
    List queryResult = getAuditReader().createQuery().forRevisionsOfEntity(SetOwningEntity.class, false, true).add(AuditEntity.id().eq(7)).add(AuditEntity.revisionType().eq(RevisionType.DEL)).getResultList();
    Object[] objArray = (Object[]) queryResult.get(0);
    Assert.assertEquals(9, getRevisionNumber(objArray[1]));
    SetOwningEntity setOwningEntity = (SetOwningEntity) objArray[0];
    Assert.assertEquals("Demo Data 2", setOwningEntity.getData());
    Hibernate.initialize(setOwningEntity.getReferences());
    Assert.assertEquals(TestTools.makeSet(new SetOwnedEntity(8, "Example Data 2")), setOwningEntity.getReferences());
}
Also used : SetOwnedEntity(org.hibernate.envers.test.entities.manytomany.SetOwnedEntity) ArrayList(java.util.ArrayList) List(java.util.List) SetOwningEntity(org.hibernate.envers.test.entities.manytomany.SetOwningEntity) Test(org.junit.Test)

Aggregations

SetOwnedEntity (org.hibernate.envers.test.entities.manytomany.SetOwnedEntity)16 SetOwningEntity (org.hibernate.envers.test.entities.manytomany.SetOwningEntity)15 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)4 List (java.util.List)4 EntityManager (javax.persistence.EntityManager)4 Priority (org.hibernate.envers.test.Priority)4 HashSet (java.util.HashSet)1 IntTestPrivSeqEntity (org.hibernate.envers.test.entities.IntTestPrivSeqEntity)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 M2MIndexedListTargetNotAuditedEntity (org.hibernate.envers.test.entities.manytomany.unidirectional.M2MIndexedListTargetNotAuditedEntity)1 CollectionRefEdEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefEdEntity)1 CollectionRefIngEntity (org.hibernate.envers.test.entities.onetomany.CollectionRefIngEntity)1 SetRefEdEntity (org.hibernate.envers.test.entities.onetomany.SetRefEdEntity)1 SetRefIngEntity (org.hibernate.envers.test.entities.onetomany.SetRefIngEntity)1 TernaryMapEntity (org.hibernate.envers.test.integration.manytomany.ternary.TernaryMapEntity)1