-->
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.  [ 6 posts ] 
Author Message
 Post subject: Unexpected Flush in Session.IsDirty
PostPosted: Thu Jun 28, 2007 5:54 pm 
Newbie

Joined: Thu Jun 28, 2007 5:26 pm
Posts: 2
I understand that NHibernate will at times automatically flush the session; however, IsDirty isn't the place I would expect this to happen.

It does this even with FlushMode set to Never.

If this is indeed necessary it should be documented somewhere.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 6:35 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
Yes, I noticed this also. Seems like a place where flushing should NEVER happen ...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 1:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
It doesn't perform a complete flush in IsDirty (no SQL is executed), but it does perform the preparation phase since that's how it detects whether any changes occurred.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 6:03 am 
Regular
Regular

Joined: Wed Apr 25, 2007 4:18 am
Posts: 51
Location: Belarus, Gomel
Hi All!

Yes, it really doesn't "execute" flush but only create "insertions/deletions/updates". Unfortunately it may lead to exception if data is somehow invalid (for example there is null in not-null pproperty). So I ended with "validate before dirty check" approach - at least in my simple case it helped to solve this problem... Until we move to more correct way of handling sessions in winforms :(

_________________
WBR, Igor


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 8:44 am 
Newbie

Joined: Thu Jun 28, 2007 5:26 pm
Posts: 2
I am seeing SQL executed in some instances (in particular with new items added to a collection). There is a call to "FlushEverything" that appears to do exactly as it's name implies.

public bool IsDirty()
{
CheckIsOpen();

log.Debug("checking session dirtiness");
if (insertions.Count > 0 || deletions.Count > 0)
{
log.Debug("session dirty (scheduled updates and insertions)");
return true;
}
else
{
int oldSize = collectionRemovals.Count;
try
{
FlushEverything();


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:19 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, there is a call to that, but it doesn't do what its name implies to you, it only fills the insertions/deletions/etc. lists.


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