O'Reilly logo

Java EE 6 Cookbook for Securing, Tuning, and Extending Enterprise Applications by Mick Knutson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Auditing historical JPA Operations

This recipe will extend the previous initial audit pattern to allow for historical audit recording. This allows for more detailed logs of who made the change, when the change occurred, and the change itself. This recipe implements a JPA Lifecycle Change Listener in order to log all CRUD operations.

Getting ready

Building upon the previous recipe, we start with a customer, and we want to audit all CRUD operations that occur. In addition to using @PrePersist and @PreUpdate annotations, we need to create two new entities to implement a JPA Lifecycle Change Listener.

Using a JPA Lifecycle Change Listener is more in depth, but allows for a more historical audit report to be kept. If you need more than just the most ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required