-->
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.  [ 11 posts ] 
Author Message
 Post subject: timeout when query is too long
PostPosted: Tue Nov 02, 2004 11:44 am 
Newbie

Joined: Tue Nov 02, 2004 11:34 am
Posts: 4
Hi all,

Basically, I would like to know if hibernate provides a way to
raise a timeout exception when a query is longer than an application-defined delay, for instance 100 ms or what ever ?

in other words, does Hibernate API provides such capability
with delay as in parameter ?

Thanks in advance for your support.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 02, 2004 7:18 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
I doubt it.

But your connection pool might, I know Proxool does (actually, it raises an error when a thread has had a connection checked out for too long, but in your case it'd probably be effectively the same).

Although that's a global setting, not on a per-query basis or anything.

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 7:26 am 
Newbie

Joined: Tue Nov 02, 2004 11:34 am
Posts: 4
Hi all,

Does next version of Hibernate will provide such capability ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 9:57 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Query.setTimeout() ?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 12:24 pm 
Newbie

Joined: Tue Nov 02, 2004 11:34 am
Posts: 4
Hi all,

Can some one tell me which kind of exception is raised when timeout ocured on a query ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 4:42 am 
Newbie

Joined: Tue Nov 02, 2004 11:34 am
Posts: 4
Hi All,

Where can I found documentation regarding
net.sf.hibernate.Query.setTimeout(int) method ?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 4:54 am 
Expert
Expert

Joined: Tue Oct 05, 2004 9:45 am
Posts: 263
well ... if you don't find a better docu, you can take a look at the source ...

gtx
curio


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 8:35 pm 
Pro
Pro

Joined: Tue Aug 26, 2003 8:07 pm
Posts: 229
Location: Brisbane, Australia
hibod wrote:
Hi All,

Where can I found documentation regarding
net.sf.hibernate.Query.setTimeout(int) method ?

Looking at the source (coz I was curious), I believe that a call to Query.setTimeout() will eventaully be translated into a call to java.sql.PreparedStatement.setQueryTimeout(). (Keep in mind that I've already been wrong once on this thread :)

Which, according to the JDBC API doc:
Quote:
Sets the number of seconds the driver will wait for a Statement object to execute to the given number of seconds. If the limit is exceeded, an SQLException is thrown.

So, I guess when you execute the query, you'll get a SQLException wrapped inside a HibernateException. I'm not sure how you could differentiate that from other kinds of errors.

_________________
Cheers,
Shorn.


Top
 Profile  
 
 Post subject: does this really work as expected?
PostPosted: Thu Apr 14, 2005 8:27 am 
Newbie

Joined: Tue Apr 12, 2005 9:50 am
Posts: 13
Location: Karlsruhe, Germany
stolley wrote:
Looking at the source (coz I was curious), I believe that a call to Query.setTimeout() will eventaully be translated into a call to java.sql.PreparedStatement.setQueryTimeout().


Has this been tested by anyone since?
I tried setting a timeout for a query and expected that a single statement will be aborted after <timeout> seconds. But it was not aborted at all ...
So I had a look at the code when a PreparedStatement is generated.
Maybe I am blind, but I did not see where the timeout-value is given from the query (i.e. in fact via a RowSelection) to the PreparedStatement (at least for executeUpdate()).

*slightly confused*
Stephan


Top
 Profile  
 
 Post subject: Re: does this really work as expected?
PostPosted: Thu Apr 14, 2005 8:35 am 
Newbie

Joined: Tue Apr 12, 2005 9:50 am
Posts: 13
Location: Karlsruhe, Germany
fudeus wrote:
So I had a look at the code when a PreparedStatement is generated.
Maybe I am blind, but I did not see where the timeout-value is given from the query (i.e. in fact via a RowSelection) to the PreparedStatement (at least for executeUpdate()).


Ok, I should have looked at Query.list() earlier.
For list(), the timeout really is implemented. I suppose it was forgotten when implementing executeUpdate() for H3 ...

I think this is a bug for JIRA (since this violates the definition of query.setTimeout()).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 15, 2005 2:32 am 
Newbie

Joined: Tue Apr 12, 2005 9:50 am
Posts: 13
Location: Karlsruhe, Germany
Hi,

ok, this is HHH-346 in JIRA. I even added a patch for this issue.
But just in case you expect this to work:
setQueryTimeout() is currrently not supported by MySQL-Server and therfore not supported by MySQL-ConnectorJ. See
http://bugs.mysql.com/bug.php?id=9906
for more information. No Exception will be thrown in case of calling it, the timeout ist just ignored.

bye,
Stephan


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