Play! Changes to wireframe historical data

I have an application that I am building on Play! Framework with a bunch of data that I would like to track changes with. In an enterprise solution, I would most likely use database triggers to copy changes to a historical table to track those changes. I'm not familiar with a similar paradigm in Play! / JPA, but maybe I am missing something. Is there a decent way to do this other than me, making a copy of all my entities and manually copying the data from the old / unchanged record to the historical one, and then saving the changes to the original model?

+3


source to share


2 answers


If data is very important to persist all data changes, then I would stick with triggers. Because since the database does the updates, so there is no possible clock skew in the cluster that the web application is running on, and if a non-JPA client is accessing the database, then you can save the updates as well.

However, if you are not so obsessed with problems like this, as I would suggest magic EntityListener

for you , for example:



  • @PrePersist
  • @PreUpdate
  • @PreRemove
  • @PostPersist
  • @PostUpdate
  • @PostRemove

You can find examples of using the EntityListener here ,

+1


source


If you are using EclipseLink JPA you can enable history support.



See, http://wiki.eclipse.org/EclipseLink/Examples/JPA/History

0


source







All Articles