javahibernatehibernate-criteriahibernate-enversaudit-tables

Get results from AuditCriterion in new class


I Know that when you do this code:

    AuditReader reader = AuditReaderFactory.get(entityManager);
    reader.createQuery().forRevisionsOfEntity(Person.class,false,true).getResultList();

it returns a tree element array. I want this 3 elements array to be mapped in a new class:

public class PersonNew {

Person person;
DefaultRevisionEntity revision;
RevisionType revisionType;

public PersonNew (Person person, DefaultRevisionEntity revision, RevisionType revisionType) {
    this.person = person;
    this.revision = revision;
    this.revisionType = revisionType;
}

}

i know that in criteria an in simple select you can do something like

select new com.package.PersonNew () from Person.

How does it apply to hibernate envers query?


Solution

  • You cannot do this in Envers currently, you will need to do the mapping yourself.