I recently added a comment to
HHH-8051 Open that outlines my plan regarding a new attribute on @Audited called targetNotFoundAction that allows specifying how Envers should handle to-one associations when the related entity cannot be located. This could be due to several reasons: 1. Related entity was originally not audited but has since been audited. 2. Related entity data was purged from the system. In the (2) scenario, the code change addresses both possible situations where a not-audited relation points to an entity that has since been removed from the main ORM tables or for situations where the audited relation points to an audit row that has since been removed from the envers tables. The implementation of the feature offers the widest configuration opportunities for users so that you can configure the system to work specific ways globally, per-class, and per-property as needed. While I think the ideal solution is that users should make sure the schema is properly populated for the tool to work, I understand that there can be scenarios where that may be super complicated or nearly impossible to do after-the-fact and thus this feature is being introduced to assist with those use cases. The feature will be marked as @Incubating, which means that it is free to change from release to release and isn't subject to the standard change policy we apply across releases for exposed APIs and SPIs. It's considered experimental and as we receive feedback, is subject to change. |