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

Assignee

Unassigned

Reporter

Luke Horsley

Labels

Components

Affects versions

Priority

Critical
Configure