0

I'm trying to use Spring JPA with Envers to keep track of audit trail of all the entities so we can go back to a point in time and inspect what the entities. I can the basic as provided by the spring-jpa-envers api like find a/ll revisions.

However is it possible to:

  1. to query for a revision with filters i.e apply filter of the entity fields? I guess we can apply filters once the revisions are return but would good find a revision from a point in time

  2. update a particular revision? In case we had a incorrect revision in the past and wanted to correct it.

Regards AU

Jens Schauder
  • 77,657
  • 34
  • 181
  • 348
A.U
  • 51
  • 6

1 Answers1

2

After some googling found the answer:

    Session session = (Session) entityManager.unwrap(Session.class);

    AuditReader auditReader = AuditReaderFactory.get(session);

    AuditQuery auditQuery = auditReader.createQuery().forRevisionsOfEntity(Country.class, true, false);
    List<Country> resultList = auditQuery.add(AuditEntity.property("name").eq("Daenemark")).getResultList();
    assertThat(resultList.size(), is(greaterThan(0)));
A.U
  • 51
  • 6