-->
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.  [ 2 posts ] 
Author Message
 Post subject: Event triggered even no SQL neccesary (no change at DB)
PostPosted: Thu Jan 10, 2008 5:32 am 
Beginner
Beginner

Joined: Mon Apr 02, 2007 8:08 am
Posts: 24
I connect listeners to events in order to make some table auditing. My problem is that after the merge() (or whatever operation I use) session is flushed and it triggers events for several objects. For example, if my session has 5 objects (connected with some cascades) I get several events triggered, even when only one of them is actually modified.

Hibernate won't trigger more SQL than neccesary, but at this point I don't know whether my event can distinguish modified objects, because it's important for me triggering auditing only at modified tables.

Is there something like ...willThisObjectTriggerSql(event.getObject())?

Thanks in advance!!

_________________
--
<a href="http://ideasse.blogspot.com/">Ideas + Software Engineering</a> (English)
<a href="http://iiso.blogspot.com/">Ideas + IngenierĂ­a del Software</a> (Spanish)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 10, 2008 12:49 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
You can check if a specific ISession contains any changes by calling:

Code:
ISession.IsDirty();


for specific instances you can implement an Interceptor to handle the auditing a simple example is found in the nhibernate reference manual chapter 9.10


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.