-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Intercepter NULL previousState even with select-befor-update
PostPosted: Fri May 13, 2005 6:47 pm 
Newbie

Joined: Fri May 13, 2005 6:26 pm
Posts: 1
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:


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.