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:
Create a parent entity with an identifier
Create a related entity which uses the identifier of the parent
Delete the related entity
Create a new related entity which uses the identifier of the parent
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.
When using a one-to-one relationship making use of foreign identifiers, the ValidityAuditStrategy crashes when the following steps are performed:
Create a parent entity with an identifier
Create a related entity which uses the identifier of the parent
Delete the related entity
Create a new related entity which uses the identifier of the parent
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.