Search in sources :

Example 1 with RevisionTypeAuditExpression

use of org.hibernate.envers.query.criteria.internal.RevisionTypeAuditExpression in project hibernate-orm by hibernate.

the class CrossTypeRevisionChangesReaderImpl method findEntities.

@Override
@SuppressWarnings({ "unchecked" })
public List<Object> findEntities(Number revision, RevisionType revisionType) throws IllegalStateException, IllegalArgumentException {
    final Set<Pair<String, Class>> entityTypes = findEntityTypes(revision);
    final List<Object> result = new ArrayList<>();
    for (Pair<String, Class> type : entityTypes) {
        result.addAll(auditReaderImplementor.createQuery().forEntitiesModifiedAtRevision(type.getSecond(), type.getFirst(), revision).add(new RevisionTypeAuditExpression(null, revisionType, "=")).getResultList());
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) RevisionTypeAuditExpression(org.hibernate.envers.query.criteria.internal.RevisionTypeAuditExpression) Pair(org.hibernate.envers.tools.Pair)

Example 2 with RevisionTypeAuditExpression

use of org.hibernate.envers.query.criteria.internal.RevisionTypeAuditExpression in project hibernate-orm by hibernate.

the class CrossTypeRevisionChangesReaderImpl method findEntitiesGroupByRevisionType.

@Override
@SuppressWarnings({ "unchecked" })
public Map<RevisionType, List<Object>> findEntitiesGroupByRevisionType(Number revision) throws IllegalStateException, IllegalArgumentException {
    final Set<Pair<String, Class>> entityTypes = findEntityTypes(revision);
    final Map<RevisionType, List<Object>> result = new HashMap<>();
    for (RevisionType revisionType : RevisionType.values()) {
        result.put(revisionType, new ArrayList<>());
        for (Pair<String, Class> type : entityTypes) {
            final List<Object> list = auditReaderImplementor.createQuery().forEntitiesModifiedAtRevision(type.getSecond(), type.getFirst(), revision).add(new RevisionTypeAuditExpression(null, revisionType, "=")).getResultList();
            result.get(revisionType).addAll(list);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) RevisionType(org.hibernate.envers.RevisionType) ArrayList(java.util.ArrayList) List(java.util.List) RevisionTypeAuditExpression(org.hibernate.envers.query.criteria.internal.RevisionTypeAuditExpression) Pair(org.hibernate.envers.tools.Pair)

Aggregations

ArrayList (java.util.ArrayList)2 RevisionTypeAuditExpression (org.hibernate.envers.query.criteria.internal.RevisionTypeAuditExpression)2 Pair (org.hibernate.envers.tools.Pair)2 HashMap (java.util.HashMap)1 List (java.util.List)1 RevisionType (org.hibernate.envers.RevisionType)1