Search code examples
javahibernatehibernate-envers

Is it possible to mix hibernate-envers versions given certain conditions?


I have a large system (A) using hibernate 4.3.11. We want to introduce auditing on a few tables using hibernate-envers.

However we want to consume the audit log on a different system (B) that uses hibernate 5.

Given that system B only reads from the shared database, is it possible to mix hibernate versions in this case?


Solution

  • Given the changes introduced to Envers between 4.3.x and 5.x release streams, there is probably a good chance you could accomplish what you're asking with minimal effort.

    I do however need to make you aware that some bugfixes in the 5.x release stream may have required some minor schema changes that may not be compatible, so be sure to test as there could be some situations based on your mappings where you may not be able to do this.

    I understand why your team may have chosen this path, but I do want to urge you to think of alternative ways to avoid sharing the database if you could.

    Eventually you may reach a point where two Hibernate/Envers versions are just not compatible or legacy feature toggles no longer exist and you're locked into using older versions with no clear upgrade path without major infrastructure changes.

    Using some type of event sourcing, trigger, data replication, message queue, etc to keep two heterogenious systems synchronized can go along way in this space allowing for the maximum amount of flexibility, least amount of coupling, and what I believe is least amount of technical debt.