Search in sources :

Example 46 with AuditReader

use of org.hibernate.envers.AuditReader in project wildfly by wildfly.

the class SLSBAudit method verifyRevisionType.

public List<Object> verifyRevisionType(int id) {
    AuditReader reader = AuditReaderFactory.get(em);
    List<Object> custHistory = new ArrayList<Object>();
    List<Number> revList = reader.getRevisions(Customer.class, id);
    for (Number revisionNumber : revList) {
        AuditQuery query = reader.createQuery().forEntitiesAtRevision(Customer.class, revisionNumber);
        query.add(AuditEntity.revisionType().eq(RevisionType.MOD));
        if (query.getResultList() != null && query.getResultList().size() > 0) {
            custHistory.add(query.getResultList());
        }
    }
    return custHistory;
}
Also used : AuditQuery(org.hibernate.envers.query.AuditQuery) ArrayList(java.util.ArrayList) AuditReader(org.hibernate.envers.AuditReader)

Example 47 with AuditReader

use of org.hibernate.envers.AuditReader in project wildfly by wildfly.

the class SLSBAuditInheritance method retrieveSoccerPlayerbyId.

public SoccerPlayer retrieveSoccerPlayerbyId(int id) {
    AuditReader reader = AuditReaderFactory.get(em);
    SoccerPlayer val = reader.find(SoccerPlayer.class, id, 1);
    return val;
}
Also used : AuditReader(org.hibernate.envers.AuditReader)

Example 48 with AuditReader

use of org.hibernate.envers.AuditReader in project wildfly by wildfly.

the class SLSBAuditMO method retrieveOldPhoneListSizeFromCustomer.

public int retrieveOldPhoneListSizeFromCustomer(int id) {
    AuditReader reader = AuditReaderFactory.get(em);
    List<Number> revList = reader.getRevisions(CustomerMO.class, id);
    CustomerMO cust_rev = reader.find(CustomerMO.class, id, revList.get(revList.size() - 1));
    return cust_rev.getPhones().size();
}
Also used : AuditReader(org.hibernate.envers.AuditReader)

Example 49 with AuditReader

use of org.hibernate.envers.AuditReader in project wildfly by wildfly.

the class SLSBOrg method retrieveOldOrgbyEntityName.

public Organization retrieveOldOrgbyEntityName(String name, int id) {
    AuditReader reader = AuditReaderFactory.get(em);
    Organization org1_rev = reader.find(Organization.class, name, id, 3);
    return org1_rev;
}
Also used : AuditReader(org.hibernate.envers.AuditReader)

Example 50 with AuditReader

use of org.hibernate.envers.AuditReader in project wildfly by wildfly.

the class SLSBOrg method retrieveDeletedOrgbyId.

public Organization retrieveDeletedOrgbyId(int id) {
    AuditReader reader = AuditReaderFactory.get(em);
    List<Number> revList = reader.getRevisions(Organization.class, id);
    /*for (Number revisionNumber : revList) {
            System.out.println("Available revisionNumber for o1:" + revisionNumber);
        }*/
    List<Object> custHistory = new ArrayList<Object>();
    AuditQuery query = reader.createQuery().forRevisionsOfEntity(Organization.class, true, true);
    query.add(AuditEntity.revisionType().eq(RevisionType.DEL));
    Organization rev = (Organization) (((List<Object>) (query.getResultList())).toArray()[0]);
    return rev;
}
Also used : AuditQuery(org.hibernate.envers.query.AuditQuery) ArrayList(java.util.ArrayList) AuditReader(org.hibernate.envers.AuditReader)

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