we are using Hibernate Envers to audit the changes of part of the data, as we introduced it only for a newer part of the application.
We have a few tables containing mainly string data for select fields (just like the “unit” for example). For auditing, I do not want to store the foreign key id in the historic data, I just would like to store the string. This will make lookups in historic data much easier.
Is there a way to replace the IDs with a certain value? Or to store additional data than just the original fields in the audited table? (or even to embed the whole referenced “column” in the _aud table?)
Or is this something you definitely never would do?
Hibernate Envers tries to mirror the part of your model which is marked as audited in audit tables and the thing you are describing can not support bidirectional data synchronization as there is no way to get back to the FK based on some column of the target table of an association. Why don’t you make that string your FK though? Is it not unique?
as there is no way to get back to the FK based on some column of the target table of an association
That’s true. Unless I store both values, the FK id, and the value. For our auditing, I only need the value.
Why don’t you make that string your FK though? Is it not unique?
We have a legacy database we are using. So right now we have to live with the IDs. We might be able to change this in near future. But if we use strings only, we have no way to fix typos or change naming of those values.
Maybe I am overcomplicating it while trying to simplify/reduce the audited entities. I need to look closer at the structure when all tables are audited to see how the lookup of old entries would work.