Create a history event
I have a spring + JPA project.
I would like to create events entries and persist them in a table, for
example:
a) Entity "User" with id 4 was changed: in property named "userName"
oldValue: "john" newValue: "johnnie"
b) A new Customer email was recieved, therfore we created a new Ticket for
this email and the assignee for this email is user named: "Goku"
My question is:
What is the best practice for creating such mechanism? currently I have 2
ideas which are not suffice:
1) I can insert the following code on every place in the code i would like
to create history event: this.historyManager.createEvent(String event
string,String newValue, String oldValue, Date date); Although this
solution works, it is extremely ugly and not generic at all.
2) Use Hibernate Envers, this library actually logs every entity change in
my project with simple annotation : "@Audited" Problem is that this
solution impacts preformance and to be honest not very appealing to me.
No comments:
Post a Comment