-->
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: Multi-threading with Hibernate
PostPosted: Tue May 16, 2006 2:36 pm 
Newbie

Joined: Tue Nov 15, 2005 8:27 pm
Posts: 19
Location: Columbia, MO USA
I'm developing a desktop Swing application that uses Hibernate 3.1.3. To avoid GUI freezes while lengthy queries and updates are being performed, I perform my queries using background threads. Everything is working fine, except I notice that Hibernate does not seem to yield processor often enough while the query runs. I need my background threads to periodically yield the processor to give the Swing event dispatch thread a chance to run so it can refresh the UI.

Any ideas?

Bruce


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 18, 2006 6:49 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
I think it has nothing to do with Hibernate but more about general Swing coding practices
* http://java.sun.com/products/jfc/tsc/ar ... eads1.html
* http://java.sun.com/products/jfc/tsc/ar ... eads2.html
* http://java.sun.com/products/jfc/tsc/ar ... eads3.html


also, are you sure that it is not about OS level memory swapping or DB execution cause the problem?

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 22, 2006 2:24 pm 
Newbie

Joined: Tue Nov 15, 2005 8:27 pm
Posts: 19
Location: Columbia, MO USA
My threads are based on a variation of the aforementioned SwingWorker class. I have threads that do not make any calls to Hibernate, and they run fine so long as I periodically call Thread.yield(). If I fail to do so, the event dispatch thread does not get much of an opportunity to run and the UI is not as responsive.

It would help if I could get Hibernate to periodically report back the progess it is making as it fetches the objects for a query. If Hibernate had some way of calling back into my application to say it has fetched 4305 objects out of 7892 total, I could put up a progress bar to give the user better feedback as to how the query is running. All the query methods that I have seen are synchronous so the thread cannot continue on and then be notified later when the query is complete.

Bruce


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.