Hi all,
We have been using hibernate for over 6 months with great experience so far.
However, I am running into a probelm which I suspect is a bug but I would like to check with other users first.
Anyway, I am trying to implement an auditlog feature using hibernate interceptor following the ideas described by Kenan Sevindik's Weblog
http://www.jroller.com/page/ksevindik/20050413.
We are using hibernate in conjunction with Spring ORM 1.1.5, with Tomcat 5.0.28, using Sun JDK 1.4.2, and on both linux and windows on 32 bit intel CPU.
Hibernate version: I tried both 2.1.7c and 2.1.8
Mapping documents (fragment):
Code:
<!-- select-before-update is set to makesure diffsets can be properly detected -->
<class name="XYZ" table="Listing" select-before-update="true">
<cache usage="read-write"/>
<id name="id" type="int" unsaved-value="-1">
<generator class="hilo">
<param name="table">XYZIdHigh</param>
<param name="column">nextHigh</param>
<param name="max_lo">256</param>
</generator>
</id>
<version name="ver" type="int" unsaved-value="negative"/>
...
</class>
Name and version of the database you are using: Postgres 7.4
Basically, on updates, when my interceptor.onFlushDirty() method is called, the previousState Object[] is null, even though I have set the select-before-update to true. Stepping in eclipse debugger thru Hibernate 2.1.8's SessionImpl code reviews that Hibernate has the ability to perform the diffset computation but called the interceptor before it does so. See line 2565-2578 in net.sf.hibernate.impl.SessionImpl.java:
Code:
//give the Interceptor a chance to modify property values
final boolean intercepted = interceptor.onFlushDirty(
object, entry.id, values, entry.loadedState, persister.getPropertyNames(), types
);
//now we might need to recalculate the dirtyProperties array
if (intercepted && !cannotDirtyCheck && !interceptorHandledDirtyCheck) {
if (dirtyCheckDoneBySelect) {
dirtyProperties = persister.findModified(currentPersistentState, values, object, this);
}
else {
dirtyProperties = persister.findDirty(values, entry.loadedState, object, this);
}
}
I would imagine the need to compute the diffset both before and after the call to the interceptor.onFlushDirty() right?
Anyway, for the time being, I am forced to hack a solution that basically do the computation in my interceptor to get the diffset.
Any additional hint/info on what I am doing wrong is greatly appreciated.
Code:
Code: