休眠:设置默认查询超时? [英] Hibernate: set default query timeout?
问题描述
我正在用Hibernate对我的数据库进行一些大的查询,而且有时会遇到超时。我想避免在每个 Query
或 Criteria
手动设置超时。
是否有任何属性可以给我的 AnnotationConfiguration
,它会为我运行的所有查询设置可接受的默认值?
如果不是的话,我怎样才能在Hibernate查询中设置一个默认的超时值呢? JPA 2定义了 javax.persistence.query.timeout 提示来指定以毫秒为单位的默认超时时间。 Hibernate 3.5(目前仍处于测试阶段)将支持该提示。
另请参阅 http://opensource.atlassian.com/projects/hibernate/browse/HHH-4662
I am doing some big queries on my database with Hibernate and I sometimes hit timeouts. I would like to avoid setting the timeout manually on every Query
or Criteria
.
Is there any property I can give to my AnnotationConfiguration
that would set an acceptable default for all queries I run?
If not, how can I set a default timeout value on Hibernate queries?
JPA 2 defines the javax.persistence.query.timeout hint to specify default timeout in milliseconds. Hibernate 3.5 (currently still in beta) will support this hint.
See also http://opensource.atlassian.com/projects/hibernate/browse/HHH-4662
这篇关于休眠:设置默认查询超时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!