Query.getSingleResult() and Query.getResultList() throw PessimisticLockException when pessimistic lock fails with a timeout in Hibernate
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7
- Hibernate 5
Issue
Content from javaee.github.io is not included.Query.getResultList() and Content from javaee.github.io is not included.Query.getSingleResult() cause a transaction rollback when the query fails with a timeout while requesting a pessimistic lock with a timeout specified.
Resolution
This issue1 is resolved in This content is not included.EAP 7.2 cumulative patch (CP) 2 and later releases. Production systems should use the latest available cumulative patch.
Root Cause
- The Hibernate code raises Content from docs.jboss.org is not included.org.hibernate.PessimisticLockException which is converted to Content from javaee.github.io is not included.javax.persistence.PessimisticLockException.
- This is a known defect (Content from hibernate.atlassian.net is not included.HHH-13364).
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.