-->
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.  [ 5 posts ] 
Author Message
 Post subject: Can I speed up Flush()?
PostPosted: Sat Sep 17, 2005 10:17 am 
Beginner
Beginner

Joined: Fri May 20, 2005 5:06 am
Posts: 28
I have 10.000 objects in memory. When I change one, and save it like the following code:

Code:
private static ISession session;
// some code
session.SaveOrUpdate(entityObject);
session.Flush();


the session.Flush() line takes 11,2 sec. I guess that NHibernate checks all objects if they changed, but they haven't. Is there any chance I can speed that up?

Thanks alot, Rainer.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 17, 2005 10:30 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Not really, but you can evict the objects that you know were not changed. Or use a separate session to save/update only those objects that you know were modified.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 17, 2005 11:11 am 
Beginner
Beginner

Joined: Fri May 20, 2005 5:06 am
Posts: 28
Hmmm. If I evict an object, because it was not changed, and later this object get changed, how can I put it in the session again?

Thanks, Rainer.

P.S.: A theoretical question: why does (N)Hibernate not makes a list of all objects, which are marked with SaveOrUpdate/Delete/Add and only checks those. Would be much faster, or didn't understand it properly?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 17, 2005 11:59 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can call Lock with LockMode.None on the object to reassociate it with the session. NH watches for changes all the objects that the session knows about. Save and Update are only used to let the session know about a new or existing object, you don't need to call Update on objects that were loaded by the session, for example. This is all explained in the manual quite well, I think.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Sep 18, 2005 9:17 am 
Beginner
Beginner

Joined: Fri May 20, 2005 5:06 am
Posts: 28
Sorry. I'm still too stupid :oops: . My problem is the following: I cleared the session, and before saving an object, I associate it to the session with session.Lock(), but there I get the following error message:

NHibernate.HibernateException: reassociated object has dirty collection reference

I thought this tells me, that the child collections are not associated with the session. So I tried to reload the collections of the object, but before that i need to associate the object with the session. So my problem is like the chicken and the egg, if you understand what I mean.

Thanks alot,
Rainer.


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