I’m working on enabling Hibernate Envers for a project and encountered an issue with pre-existing data in the database before auditing was enabled. When I try to retrieve an audit that references an entity added before auditing was enabled, I get an org.hibernate.ObjectNotFoundException
.
For example, the patient entity has a patient_identifier_type
field. Since the patient identifier types were added before auditing was enabled, they don’t exist in the audit table (patient_identifier_type_AUD
). This results in an org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.openmrs.PatientIdentifierType#2]
when I retrieve a patient audit.
Is this an expected behavior?
I understand that one solution is to seed the audit tables manually, but I’m wondering if there are any alternative workarounds for handling this. Any suggestions would be appreciated. Thank you!