It is sometimes a desired practice to place the Envers audit tables in a separate schema from the Hibernate entity model tables.
Such a setup can be easily realized by either providing the {{default_catalog_name}} or the {{default_schema_name}} configuration property for Envers.
The problem is when the user decides to eliminate the default tables for the audit table _prefix_ and/or _suffix_ to force the Enver's schema table names to be identical to those in the main ORM schema. Doing so causes a {{DuplicateMappingException}} to occur.
The work around solution to have the same table names in both schemas but differing entity registrations with ORM is a bit tedious and requires that the default _prefix_ / _suffix_ logic continue to be used (e.g. appending _AUD as a suffix), but then explicitly setting the audit table names on the entities using {{@AuditTable}} annotation.
It would be better if we could streamline this configuration so that we avoid the exception and simultaneously avoid having to be as explicit with the {{@AuditTable}} usage. See http://stackoverflow.com/a/38386021/1572269 for details. |
|