Search in sources :

Example 11 with AuditQuery

use of org.hibernate.envers.query.AuditQuery in project hibernate-orm by hibernate.

the class EmbeddableQuery method testAuditQueryUsingEmbeddableNonEqualityCheck.

@Test
public void testAuditQueryUsingEmbeddableNonEqualityCheck() {
    try {
        final NameInfo nameInfo = new NameInfo("John", "Doe");
        final AuditQuery query = getAuditReader().createQuery().forEntitiesAtRevision(Person.class, 1);
        query.add(AuditEntity.property("nameInfo").le(nameInfo));
    } catch (Exception ex) {
        assertTyping(AuditException.class, ex);
    }
}
Also used : AuditQuery(org.hibernate.envers.query.AuditQuery) AuditException(org.hibernate.envers.exception.AuditException) AuditException(org.hibernate.envers.exception.AuditException) Test(org.junit.Test)

Example 12 with AuditQuery

use of org.hibernate.envers.query.AuditQuery 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 13 with AuditQuery

use of org.hibernate.envers.query.AuditQuery 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

AuditQuery (org.hibernate.envers.query.AuditQuery)13 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)3 AuditReader (org.hibernate.envers.AuditReader)3 AuditException (org.hibernate.envers.exception.AuditException)1