Reputation: 332
I am doing lots of rnd to do auditing for a big project. The project will be entirely beased on Spring framework with JPA and Hibernate to do the data mapping part. For auditing I have came across various features and technology. Use Hibernate interceptors. Use Hibernate Event listeners. Hibernate Envers Spring AOP. I even tried creating and maintaining my own AUDIT table.
So far I am considering Hibernate Envers as my best bet as it reduces the manual coding and its versioning features is very interesting. Since it is a relatively new technology I don't have very much idea and I want to be pretty sure before implementing this as a part of solution.
So please suggest me which will technology will be best suited? Will Hibernate Envers be able to deal with complex business scenarios? Need some expert advice.
Upvotes: 4
Views: 2394
Reputation: 390
Envers will track every change to your entities, and allow you to look at the complete history since it creates a table to store the state of your entity at any revision. That table can get very large quickly depending on how often your entities change and how many there are. However, like you stated above, Envers is probably the easiest solution since you can just drop in a few annotations and you are done.
It mostly depends on your application and what you want to log. It might be better to write your own code to do logging (or use triggers) if Envers is too noisy or logs extra information that you don't need.
Upvotes: 2