I have an entity class manged by with JPA, and I have one entity that needs to be loged changes in its property. Does JPA provides any ways to handle this kind of requirement ?
If you use Hibernate as JPA provider then have a look at Hibernate-Envers.
If you use Spring, then have at Hades, or its successor Spring-Data-JPA.
Both (Envers and Hades/Spring-Data-JPA) provide auditing functionality. Hibernate Envers is very powerful and Hades/Spring-Data-JPA is more light (Hades reference, chapter auditing).
If you do not want/can use any of them, then may you have to hook in the entity lifecycle. with @PostUpdate and co.
See,
http://en.wikibooks.org/wiki/Java_Persistence/Advanced_Topics#History
and,
http://en.wikibooks.org/wiki/Java_Persistence/Auditing_and_Security
If you are using EclipseLink it include historical support. You can enable a class to have all of its changes tracked in a separate historical table.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With