One-to-one using ValidityAuditStrategy does not support update of entities after deletion

Description

When using a one-to-one relationship making use of foreign identifiers, the ValidityAuditStrategy crashes when the following steps are performed:

  1. Create a parent entity with an identifier

  2. Create a related entity which uses the identifier of the parent

  3. Delete the related entity

  4. Create a new related entity which uses the identifier of the parent

  5. Update the new related entity

I believe this is caused because when an update is performed, envers looks for the audit entry where the end_rev is null and the id matches, with these steps this results in two results.

Perhaps for a one-to-one, when a new related entity is created, the previous audit entry should get its end_rev field populated with this revision.

I have enclosed a patch which also includes a minor fix for PrimaryKeyJoinColumn/Mapping.hbm.xml which was required before I was able to run the test.

Environment

Using ValidityAuditStrategy

Attachments

1

Activity

Show:

Roger 
March 27, 2014 at 3:00 PM

Luke Horsley 
March 17, 2014 at 3:56 PM

I implemented the test using the main branch, however this also affects our production app which is running version 1.6.0.

Details

Assignee

Reporter

Labels

Components

Affects versions

Priority

Who's Looking?

Open Who's Looking?
Created March 17, 2014 at 3:44 PM
Updated March 27, 2014 at 3:00 PM
Who's Looking?