-->
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.  [ 4 posts ] 
Author Message
 Post subject: Interceptor is not being called on all changes
PostPosted: Wed Jul 20, 2005 11:44 am 
Newbie

Joined: Tue May 25, 2004 11:42 am
Posts: 10
Location: Oxford, England
Hi,

I am trying to use an Interceptor to capture changes to my objects. This is working great on all changes except updates to lists.

If I have an Object like the following :
Code:
public class Company implements PolicyContainer {

    private int companyId;
    private String companyName;
    private List aList;
....
}

where aList is mapped into a bag
Code:
<class name="Company" table="company" select-before-update="true" >
      <id name="id" type="int" column="companyID" unsaved-value="0">
         <generator class="native"/>
      </id>
        <bag name="aList" table="aListTable" cascade="all">
            <key column="companyID"/>
            <composite-element class="aListClass">
                <property name="id" column="id" type="int" />
                <property name="fred" column="fred" type="string"/>
            </composite-element>
        </bag>
   </class>


If I alter the companyName attribute on a company object then flush() the session then the Interceptor.onFlushDirty() method is called.
If however I add a new aListClass object to the aList list and flush() the session then the Interceptor.onFlushDirty() method is not called.

This seems wrong to me. Have I done something wrong or is it a bug?

I am running Hibernate version 3.0.5, 25 May 2005 with JDK1.5.0_02.
Code:


Top
 Profile  
 
 Post subject: Re: Interceptor is not being called on all changes
PostPosted: Wed Jul 20, 2005 12:40 pm 
Newbie

Joined: Thu Jul 14, 2005 5:19 am
Posts: 7
Location: Munich, Germany
johnnyRhino wrote:
Hi,

I am trying to use an Interceptor to capture changes to my objects. This is working great on all changes except updates to lists.

...

If I alter the companyName attribute on a company object then flush() the session then the Interceptor.onFlushDirty() method is called.
If however I add a new aListClass object to the aList list and flush() the session then the Interceptor.onFlushDirty() method is not called.

This seems wrong to me. Have I done something wrong or is it a bug?
[code][/code]


Well, that depends... :-)

I haven't used interceptors yet and I am new to Hibernate. However, here's a good guess: When you add a NEW aListClass (object), there's no dirty object to be flushed. Instead, a new object is saved (onSave). The "company" (table) is not affected by this operation. ONE new object is saved, NO old objects are modified (in the database).

That seems correct to me :-)))

HTH,

Holger


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 21, 2005 4:42 am 
Newbie

Joined: Tue May 25, 2004 11:42 am
Posts: 10
Location: Oxford, England
That is not correct. The object in question is being altered because it encapsulates the list. I have monitored the onSave() method as well and it is not being called either. Basically, for a change of the type as described earlier only the preFlush() and postFlush() methods on the interceptor are being called.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 22, 2005 8:09 am 
Newbie

Joined: Thu Sep 22, 2005 8:02 am
Posts: 1
I have the same problem. Does anybody have a solution?
Audit logging without logging changes in collections is incomplete.
For example changes in many-to-many relations cannot be logged.


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

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.