-->
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: how to pass timeout value in a hibernate call.
PostPosted: Thu Feb 16, 2012 6:21 am 
Newbie

Joined: Mon Jun 14, 2010 7:37 am
Posts: 7
Hi

I have a scenario, I would like to set timeout value for hibernate call. but i don't find the way to set timeout.

I found many search results like <property name="hibernate.c3p0.timeout" value="300" /> i am not using this.

Please help me to set timeout value for a hibernate call.

I tried transaction.setTimeout() not working.

-Kiran


Top
 Profile  
 
 Post subject: Re: how to pass timeout value in a hibernate call.
PostPosted: Thu Feb 16, 2012 6:39 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
What do you exactly mean with "hibernate call" ?

Do you want in first line, take control of queries which taking to long time to execute?
Or do you have indeed problems with updates hanging because of locks on the database?

This are 2 completely different scenarios which have to be threated separetely.


Top
 Profile  
 
 Post subject: Re: how to pass timeout value in a hibernate call.
PostPosted: Thu Feb 16, 2012 6:59 am 
Newbie

Joined: Mon Jun 14, 2010 7:37 am
Posts: 7
we have some db calls and we are using hibernate to communicate with db.

some of the db calls is taking long time to get the data. so we would like to put time out value for all hibernate calls in our code. is it possible.


Top
 Profile  
 
 Post subject: Re: how to pass timeout value in a hibernate call.
PostPosted: Thu Feb 16, 2012 7:22 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
I tried transaction.setTimeout() not working.


transaction.setTimeout() only works if you use the JTA (Java Transaction Api) approach where you also have to use a TransactionManager.
(Usually the JTA approach is only used when using hibernate within an J2EE-ApplicationServer)

On queries you can do the following:

Quote:
Query q=session.createQuery("from Item").setTimeout(60); // 1 minute


But if this effectively works, depends on the jdbc-driver you use.
You have to check if/how your jdbc-driver does implement the method Statement.setQueryTimeout().

But beside all of this, as first step I suggest to analyze why certain calls take long time.
Is it because of an index missing on a column, or is it because your query is waiting the release of locks,
or maybe the db-engine is already investing 100% cpu otherwise ?
I suggest you to analyze all calls with p6spy (and eventually also with http://sourceforge.net/projects/sqlprofiler/) , so you can see which
calls take long time.
Maybe a simple creation of an index could resolve all your performance problems ...


Last edited by pb00067 on Fri Feb 17, 2012 2:53 am, edited 2 times in total.

Top
 Profile  
 
 Post subject: Re: how to pass timeout value in a hibernate call.
PostPosted: Thu Feb 16, 2012 7:35 am 
Newbie

Joined: Mon Jun 14, 2010 7:37 am
Posts: 7
Thanks for your reply for setting up timeout value on query object.

Also thanks for your suggesting on db tuning like creation of index. if I need any help I will post again.


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.