-->
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: Query timeout with PostgreSQL
PostPosted: Sat Feb 06, 2010 12:21 am 
Newbie

Joined: Fri Feb 05, 2010 11:34 pm
Posts: 7
How can I implement query timeout with Hibernate and PostgreSQL? Unfortunately, query.setTimeout(int) doesn't work, because the PostgreSQL JDBC driver ignores it.

JIRA has a brief mention of new support for Postgres.
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4765

How do I access it? PostgreSQL SQL has no "SELECT ... FOR UPDATE WAIT 1000" construct as is mentioned in the JIRA for Oracle. The official PostgreSQL method of query timeout is with the SQL statement:

SET LOCAL statement_timeout TO 1000;

But I can't find a way to execute a SQL "SET" statement with a Hibernate EntityManager native query.

This is a pretty basic issue -- does anybody have a clue?

Thanks,
--Steve


Top
 Profile  
 
 Post subject: Re: Query timeout with PostgreSQL
PostPosted: Sat Feb 06, 2010 12:41 am 
Newbie

Joined: Fri Feb 05, 2010 11:34 pm
Posts: 7
Perhaps this is the intended usage (JPA 2/JEE 6):

query.setHint("javax.persistence.lock.timeout", new Integer(timeout));

This didn't work for me with Hibernate 3.2. Is there anything that will work with a current Hibernate release?

Thanks,
--Steve


Top
 Profile  
 
 Post subject: Re: Query timeout with PostgreSQL
PostPosted: Wed Jan 05, 2011 4:14 pm 
Beginner
Beginner

Joined: Thu Jun 21, 2007 1:47 pm
Posts: 46
FWIW I think you could probably do this by accessing the JDBC connection directly and running an executeUpdate("SET LOCAL statement_timeout = 60000") or something along those lines.


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.