Posts

JPA Auditing using AOP using old and new values

Image
  This article is about using the power of Java Persistence API to create Auditing handlers. Following are the steps to accomplish that. 1.        Create a hibernate entity, repository and Spring MVC controller using SpringBoot 2.        Create marker annotation to mark the repository as Auditable 3.        Create the AOP for intercepting entity saving action. Following code creates aspect for saving the entity. When save is called on the repository, the following code on line 22 will be executed. 4.        Write the corresponding handler Note the following piece of code. It verifies if the annotation AUDITABLE_REPO is present for the repository. If the annotation is present, it returns the class. The handler(coded above) further checks if the Interface is present before invoking the AOPed method. Now the problem is to get the old values as...