Hello,
Well I've been using Hibernate for a couple of years, but my problem doesn't seem to thematically "fit" into one of the other forums, so I guess I'll have to post it here ;)
In Hibernate 2.1.2, I have a persistent class that has a persistent property: "lastUpdateDate". The semantic of this property is the conventional one: every time there is a change to some persistent properties in this class, when those changes are propogated (committed) to the database, the "lastUpdateDate" property and corresponding column value should be updated with the current timestamp.
The problem I'm having is finding a single hook that covers all of the different Hibernate methods for propogating changes to the database.
For instance, if I try to implement my lastUpdateDate functionality in the Lifecycle methods, onSave() and onUpdate(), I don't catch changes to my persistent class that are propogated to the database with this construct:
Session aSession = //assume we get a Session
PersistentObject aPersistentObject = // assume we fetch this object in aSession
Transaction aTransaction = aSession.beginTransaction();
aPersistentObject.setPersistentProperty(aNewValue);
aTransaction.commit();
In this scenario, aNewValue is propogated to the db for "persistentProperty", but none of the Lifecycle methods are ever called.
Is there a lower (than the Lifecycle methods) level hook where I can implement my timestamping?
thanks,
joe
|