Hello. There is very useful (for me at least) implementation of audit info in the Hibernate communiti area:
http://www.hibernate.org/48.html
1. Original solution is probably for very old version of Hibernate because does not implement all of Interceptor methods. There is followup (
http://www.hibernate.org/48.43.html ) which adds these methods. But for me it has a big problem - to check if old and new values are the same, it uses old.toString().equals(new.toString()) or something like that.
Imho, this is terrible. I looked at Hibernate sources but found no easy way to compare current and previous state of an object. Ideal solution would be to let Hibernate perform dirty check by itself and then only modify the list of dirty columns.
Is it possible?
2. I would like to modify the Audit Info to let user Id be any object not just Long. But in this case i have problems in nullSafeSet/nullSafeGet because I do not know how to bind/get values properly. Is it possible to configure custom type from Hibernate's mapping files?