Envers: ValidityAuditStrategy should support non-generated PKs

Description

I have an entity for storing String key-value pairs (the equivalent of a properties file). The String key is the primary key – it's not generated, and there is no other generated id. It's not possible to use ValidityAuditStrategy for auditing changes to this entity. The problem is when a row is deleted and later another row is inserted with the same key as the deleted one.

When a row is deleted, a revision of type DEL is added, with the REVEND column set to null. When a row is added with the same PK, a revision of type ADD is added, with the REVEND column set to null. A subsequent call to update the row fails, because ValidityAuditStrategy expects to find exactly one row with a null REVEND value, but at this point there are 2 rows.

The ADD revision should update the REVEND column of the DEL revision, or the DEL revision can set rev = revend = revision at which the del happened.

See http://community.jboss.org/message/594167.

Activity

Chris CranfordMay 22, 2016 at 1:45 AM

This seems to have been resolved with HHH-8280.
The solution in this case is to enable the setting org.hibernate.envers.allow_identifier_reuse=true.

Former userAugust 16, 2011 at 2:57 AM

Adam, please assign as appropriate.
Thanks,
Gail

Duplicate

Details

Assignee

Reporter

Priority

Created May 9, 2011 at 3:59 PM
Updated December 3, 2024 at 9:29 AM
Resolved May 22, 2016 at 1:46 AM

Flag notifications