shashdr
shashdr

Reputation: 73

Hibernate Envers: Retrieve revision type deleted entries

AuditQuery query = auditReader.createQuery()
                     .forRevisionsOfEntity(AB.class, false, true)
                     .add(AuditEntity.property("bId").eq(bId))
                     .addOrder(AuditEntity.revisionNumber().desc());

The above code retrieves all revisions except RevType DEL revisions as bId column is null.

I have three Tables A, B, and AB. AB table is a relationship table. So AB table has abID as PK, and aId, bID, Revision Info. Whenever B is deleted, it updates AB_AUDv table with revtypeDELand keepsaid,bidasnull`.

To display the deleted B, can anyone suggest me with a modified auditreader query?

Upvotes: 3

Views: 5441

Answers (1)

adamw
adamw

Reputation: 8636

You can either:

  • store data at delete time (Envers docs, org.hibernate.envers.store_data_at_delete)
  • query for the entity at the (revision it was deleted at) - 1.

Upvotes: 6

Related Questions