Search in sources :

Example 6 with AuditReader

use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.

the class CustomBoxed method testFindRevisions.

@Test
public void testFindRevisions() {
    AuditReader vr = getAuditReader();
    Set<Number> revNumbers = new HashSet<Number>();
    revNumbers.add(1);
    revNumbers.add(2);
    Map<Number, CustomBoxedRevEntity> revisionMap = vr.findRevisions(CustomBoxedRevEntity.class, revNumbers);
    assert (revisionMap.size() == 2);
    assert (revisionMap.get(1).equals(vr.findRevision(CustomBoxedRevEntity.class, 1)));
    assert (revisionMap.get(2).equals(vr.findRevision(CustomBoxedRevEntity.class, 2)));
}
Also used : AuditReader(org.hibernate.envers.AuditReader) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with AuditReader

use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.

the class CustomColumnMapping method testFindRevision.

@Test
public void testFindRevision() {
    AuditReader vr = getAuditReader();
    long rev1Timestamp = vr.findRevision(CustomRevEntityColumnMapping.class, 1l).getCustomTimestamp();
    assert rev1Timestamp > timestamp1;
    assert rev1Timestamp <= timestamp2;
    long rev2Timestamp = vr.findRevision(CustomRevEntityColumnMapping.class, 2l).getCustomTimestamp();
    assert rev2Timestamp > timestamp2;
    assert rev2Timestamp <= timestamp3;
}
Also used : CustomRevEntityColumnMapping(org.hibernate.envers.test.entities.reventity.CustomRevEntityColumnMapping) AuditReader(org.hibernate.envers.AuditReader) Test(org.junit.Test)

Example 8 with AuditReader

use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.

the class CustomPropertyAccess method testFindRevision.

@Test
public void testFindRevision() {
    AuditReader vr = getAuditReader();
    long rev1Timestamp = vr.findRevision(CustomPropertyAccessRevEntity.class, 1).getCustomTimestamp();
    assert rev1Timestamp > timestamp1;
    assert rev1Timestamp <= timestamp2;
    long rev2Timestamp = vr.findRevision(CustomPropertyAccessRevEntity.class, 2).getCustomTimestamp();
    assert rev2Timestamp > timestamp2;
    assert rev2Timestamp <= timestamp3;
}
Also used : AuditReader(org.hibernate.envers.AuditReader) CustomPropertyAccessRevEntity(org.hibernate.envers.test.entities.reventity.CustomPropertyAccessRevEntity) Test(org.junit.Test)

Example 9 with AuditReader

use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.

the class Inherited method testFindRevision.

@Test
public void testFindRevision() {
    AuditReader vr = getAuditReader();
    long rev1Timestamp = vr.findRevision(InheritedRevEntity.class, 1).getTimestamp();
    assert rev1Timestamp > timestamp1;
    assert rev1Timestamp <= timestamp2;
    long rev2Timestamp = vr.findRevision(InheritedRevEntity.class, 2).getTimestamp();
    assert rev2Timestamp > timestamp2;
    assert rev2Timestamp <= timestamp3;
}
Also used : AuditReader(org.hibernate.envers.AuditReader) Test(org.junit.Test)

Example 10 with AuditReader

use of org.hibernate.envers.AuditReader in project hibernate-orm by hibernate.

the class Listener method testFindRevisions.

@Test
public void testFindRevisions() {
    AuditReader vr = getAuditReader();
    Set<Number> revNumbers = new HashSet<Number>();
    revNumbers.add(1);
    revNumbers.add(2);
    Map<Number, ListenerRevEntity> revisionMap = vr.findRevisions(ListenerRevEntity.class, revNumbers);
    assert (revisionMap.size() == 2);
    assert (revisionMap.get(1).equals(vr.findRevision(ListenerRevEntity.class, 1)));
    assert (revisionMap.get(2).equals(vr.findRevision(ListenerRevEntity.class, 2)));
}
Also used : AuditReader(org.hibernate.envers.AuditReader) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

AuditReader (org.hibernate.envers.AuditReader)51 Test (org.junit.Test)27 Car (org.hibernate.envers.test.integration.query.entities.Car)8 EntityManager (javax.persistence.EntityManager)6 HashSet (java.util.HashSet)5 ArrayList (java.util.ArrayList)4 AuditQuery (org.hibernate.envers.query.AuditQuery)4 List (java.util.List)2 Map (java.util.Map)2 Query (javax.persistence.Query)2 Session (org.hibernate.Session)2 DefaultRevisionEntity (org.hibernate.envers.DefaultRevisionEntity)2 CustomRevEntity (org.hibernate.envers.test.entities.reventity.CustomRevEntity)2 AuditedDataPoint (org.hibernate.osgi.test.client.AuditedDataPoint)2 ServiceReference (org.osgi.framework.ServiceReference)2 Date (java.util.Date)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 PersistenceProvider (javax.persistence.spi.PersistenceProvider)1 SessionFactory (org.hibernate.SessionFactory)1 CustomPropertyAccessRevEntity (org.hibernate.envers.test.entities.reventity.CustomPropertyAccessRevEntity)1