jpahibernate-enversnhibernate-envers

using revision tables to store business data?


we use Hibernate Envers in our project to store a complete revision of all our database tables.

Would you advice to use these shadow tables for the retrieval of business data (e.g. creationDateTime/modificationDateTime/business "history" of an entity) or would it be a far better practice to integrate the business data within the business entity (somehow duplicating it of course as the shadow tables also store e.g. the creation date time) and just let envers work its magic?

Please keep in mind, that access and retrieval from envers tables is sometimes not most effective.

Thanks in advance!


Solution

  • The main Envers use-case is for data auditing, so keeping a record of the changes, not necessarily business features. However, if the performance characteristics are fine (I would recommend using Validity Audit Strategy in such case), I don't see why you wouldn't use the built-in versioning that Envers provides.