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.
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.