Query.getSingleResult() and Query.getResultList() throw PessimisticLockException when pessimistic lock fails with a timeout in Hibernate

Solution Verified - Updated

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

Components
Category

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.