History tables and error logging
Hi,
[I hope this is the right forum]
I need to track all updates to the database in my application. I mean, all versions of a record must be kept.
For example, in my DAO, if I have a method like
Code:
public User update_updateUser(User user) {
getHibernateTemplate().saveOrUpdate(user);
}
I want to make this run as:
Code:
public User update_updateUser(User user) {
BackupUser backupUser=new BackupUser(User);
getHibernateTemplate().save(backupUser);
getHibernateTemplate().saveOrUpdate(user);
}
For each entity, I will need to create another entity (Like BackupUser), which maps to another database table (Like BACKUP_USER).
I would like to learn if it is possible, by use of AOP, to have the functionality I mentioned above - without handcoding manually for each Hibernate call.
Another similar requirement is error logging. Whenever Spring catches an Exception, I would like to run this code:
Code:
ApplicationErrorLog appErrorLog = new(ApplicationErrorLog);
getHibernateTemplate().save(applicationErrorLog );
I know that I have to read a lot about AOP, but until then, your help, simple code examples and appcontext.xml will be will be very much appreciated.
Regards,
Turgay Zengin