In my cuurnet project, I have a need to log information whenever a column is updated (for auditing purposes). So for a given object and a property, I need to log the TableName, ColumnName, OldValue, NewValue.
I am experimenting with the MetaData API and EntityPersister class to get the Table Name and ColumnName. While I could easily get the TableName using EntityPersister.getTableName(), the EnityPersister.getProperyColumnNames(int i) gives the alias names of the column and not the actual column. I see another method getActualPropertyColumnNames() that may do the job, but it is a protected method. What should I do to get the Column Name of a given property?
Also, is a there a commonly used way or a pattern to capture the new and old value and log it (or even persist it in some kind of audit table)?
|