-->
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: avoiding automatic flushes in hibernate
PostPosted: Thu Dec 25, 2008 7:38 pm 
Newbie

Joined: Thu Dec 25, 2008 7:33 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2


hi.. we have log of "read-only" objects in our database and i've noticed using a profiler, calls though query and critira invoke flushes which take a long time, is it reasobile to turn off the flush just before the these specfic calls, and turn it back on again.

this also happens even if the objects are located in 2nd level cache, which always made me wonder why our processes are still slow.

what are queryspaces ? i heard they are related some how.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 30, 2008 7:26 pm 
Newbie

Joined: Tue Dec 30, 2008 6:20 pm
Posts: 4
Location: Bulgaria
You can control automatic flush using the following:
Code:
session.setFlushMode(FlushMode.MANUAL)
session.setFlushMode(FlushMode.AUTO)

or
Code:
query.setFlushMode(FlushMode.MANUAL)
query.setFlushMode(FlushMode.AUTO)

or
Code:
criteria.setFlushMode(FlushMode.MANUAL)
criteria.setFlushMode(FlushMode.AUTO)

_________________
Nikolai Gagov


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 07, 2009 4:24 pm 
Expert
Expert

Joined: Sat Jan 17, 2004 2:57 pm
Posts: 329
Location: In the basement in my underwear
ngagov has it right,

you can manually control the flushing by setting the flush modes at runtime. Btw, thanks ngagov, I never noticed that the Criteria API exposed that.

hi_user,
As for queryspaces, they are essentially the tables that will be read during a query. During auto flushing, hibernate will look to see what tables you will be querying against and if there are dirty objects in your session that refer to these tables then the actual flush will occur.

If your flushes are taking a very long time you may also want to consider flushing and clearing your session from time to time to keep it manageable. If you're using the Query API you can also tag the query as read only which will avoid creating the db snapshot for the object. There's been some chatter in the JIRA section to allow the same type of functionality for Criteria queries as well.

_________________
Some people are like Slinkies - not really good for anything, but you still can't help but smile when you see one tumble down the stairs.


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.