0

I have an envers query to look up the history of a given entity, what I am trying to do is make use of the predicates if they are specified in the request.

For example I would like the ability to filter by date/user/revision type etc (or a combination of fields) based on the request sent.

I know how to add predicates, I'm just wondering is there a default value I can use if the parameter (for example fromDate) is not specified and therefore the following line is ignored.

.add(AuditEntity.revisionProperty("date").ge(fromDate))

1 Answer 1

2

From further reading on this i've found the solution to be similar to this answer; https://stackoverflow.com/a/2439958/7030856

AuditReader reader = AuditReaderFactory.get(entityManager);
AuditQuery query = reader.createQuery().forRevisionsOfEntity(cls, true, true);
if (fromDate!= null) {
    query.add(AuditEntity.revisionProperty("date").ge(fromDate))
}
// Etc
List<Object[]> changes = query.getResultList();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.