Reputation: 5977
Following is Table Structure:
id | createdby | createddate | tablename | columnname | primaryid | oldavalue | newvalue | remarks
we get delimited file in which we have some values to update in 4 tables. Four tables have 10 Columns each. We do not know what to update. So we just update whole row against one Primary ID.
Now Challenges here are:
How to get Table Name, Column Name in Hibernate?
How to fetch Old Value; during an update? How to know which field we are updating has old value and we are now inserting new value? (We don't compared fields yet)
Upvotes: 1
Views: 3216
Reputation: 4273
My favorite tool for this is Hibernate Envers. You just annotate your entities as @Audited and envers takes care of the interceptors.
Upvotes: 2
Reputation: 272
You can also use Spring AOP by writing a spring aspect before and after the execution of operation which will insert the data in audit tables
Upvotes: 0
Reputation: 303
You can Implement EmptyInterceptor of Hibernate. In methods of EmptyInterceptor you are able to find the field name, previous value and current value.
Upvotes: 3