About Abhishek Somani
To Maintain history of database or keep track of modification of database table row , we create a version table that contains fields identical to original table.Whenever original table gets changed , we create another entry in version table. So for every update query , we have to write an insert query in version table . There is a module available in hibernate to manage easy auditing of objects , and we don’t have to write separate insert query by ourselves.
Hibernate Envers provides in built mechanism to maintain history of objects in database . Envers is library for Hibernate that will help us to easily achieve audit functionality. This has been created by Adam Warski. From Hibernate 3.5, Envers is included as a Hibernate core module. Let’s take an example as to how Envers can be used to maintain history of objects.
Here is the pom dependency for Envers (Version will be same as your hibernate core and entity manager):
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-envers</artifactId> <version>4.0.1.Final</version> </dependency>
Source : http://www.javacodegeeks.com/2013/09/how-to-maintain-history-of-tables-in-hibernate.html