-->
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.  [ 3 posts ] 
Author Message
 Post subject: fetch read-only objects
PostPosted: Mon Oct 17, 2005 9:26 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
Hi

Is it possible to fetch read-only "snapshot" of objects with ICriteria or IQuery? (with lazy loading enabled as usual).
E.g. when I am fetching array of 2000 objects, just for displaying them, NHibernate sometimes transparently update all of them with 2000 UPDATE queries, hanging my app for long time (15 sec on my machine).

To avoid the problem I have a loop:
Code:
        For Each dok As Document In list_full
            ses.Evict(dok)
        Next


But it has two disadvantages:
1) it's an ugly piece of code
2) I cannot use lazy loading after "evicting" an object

Any suggestions?

_________________
michal


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 11:38 am 
Beginner
Beginner

Joined: Wed Jun 29, 2005 10:40 am
Posts: 30
Location: denver, co
To avoid transparent persistence, set the FlushMode property of your session to Never or Commit. This will prevent those updates unless you explicitly call Flush() on the session, and it will enable lazy-loading for all of your objects.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 3:50 am 
Regular
Regular

Joined: Mon Jul 18, 2005 4:10 am
Posts: 92
Location: Poland
It works! Big thanks.

_________________
michal


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