[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6846?page=c...
]
Christian Bauer commented on HHH-6846:
--------------------------------------
Additionally, there is currently no way to get a lock timeout into an explicit query such
as the example above.
The javax.persistence.lock.timeout setting is recognized as a global property for the
EntityManager/EMF, and apparently used for on-startup query generation and
em.find(LockModeType), but never applied to manually created queries.
JPA also defines overriding precedence, so we can't just ignore the global setting and
apply only the local setting.
Support for Query.setHint(javax.persistence.lock.timeout)
---------------------------------------------------------
Key: HHH-6846
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-6846
Project: Hibernate Core
Issue Type: New Feature
Reporter: Christian Bauer
Priority: Minor
"This hint may be used with the methods of the EntityManager interface that allow
lock modes to be specified, the Query.setLockMode method and the NamedQuery
annotation."
List<Item> items =
em.createQuery("select i from Item i where i.category.id = :catId")
.setLockMode(LockModeType.PESSIMISTIC_WRITE)
.setParameter("catId", categoryId)
.setHint("javax.persistence.lock.timeout", 5000) // Currently
ignored!
.getResultList();
This should be quite easy to implement:
- org.hibernate.ejb.AbstractQueryImpl#setHint() needs to recognize the new property
- similar to the abstract applyTimeout() a new method applyLockTimeout() can be added
- the implementation in org.hibernate.ejb.QueryImpl calls the
org.hibernate.Query.setLockOptions(...) method on its delegate
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira