[hibernate-issues] [JIRA] (HHH-14110) "no transaction is in progress" when call entity manager find() with LockModeType

Alex Popa-Tesileanu (JIRA) jira at hibernate.atlassian.net
Fri Jul 17 06:26:08 EDT 2020


Alex Popa-Tesileanu ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f1170da1a26ad00144c09d2 ) *created* an issue

Hibernate ORM ( https://hibernate.atlassian.net/browse/HHH?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 ) / Improvement ( https://hibernate.atlassian.net/browse/HHH-14110?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 ) HHH-14110 ( https://hibernate.atlassian.net/browse/HHH-14110?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 ) "no transaction is in progress" when call entity manager find() with LockModeType ( https://hibernate.atlassian.net/browse/HHH-14110?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 )

Issue Type: Improvement Affects Versions: 5.4.18 Assignee: Unassigned Components: hibernate-core Created: 17/Jul/2020 03:26 AM Environment: java 11,
hibernate 5.4.18,
JTA: narayana-jta-5.9.0,
SQL Server 2016
Windows 10
Labels: hibernate jta Priority: Major Reporter: Alex Popa-Tesileanu ( https://hibernate.atlassian.net/secure/ViewProfile.jspa?accountId=5f1170da1a26ad00144c09d2 )

When I use entity manager find() method with LockModeType inside JTA transaction boundaries, throw fowling exception:

_Exception in thread "main" javax.persistence.TransactionRequiredException: no transaction is in progress
at org.hibernate.internal.AbstractSharedSessionContract.checkTransactionNeededForUpdateOperation(AbstractSharedSessionContract.java:413)
at org.hibernate.internal.SessionImpl.checkTransactionNeededForUpdateOperation(SessionImpl.java:3395)
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3310)
at org.hibernate.internal.SessionImpl.find(SessionImpl.java:3292)
at ro.alsoco.tt.test.TestJPA.run(TestJPA.java:71)
at ro.alsoco.tt.test.TestJPA.main(TestJPA.java:24)
_

This doesn't happen when I use for example createQuery or if i call clear() or flush() before find().
After a few research I saw the majority of entity manipulation methods of EntityManager (SessionImpl or AbstractSharedSessionContract classes) execute on begining pulseTransactionCoordinator(). But find() mehod not.
I don't know if there are any special reason why find method not call pulseTransactionCoordinator(), witch I saw register synchronization with JTA.
For the moment I solved my problem issuing a joinTransaction() as first command after begin transaction.

Also, the problem doesn't happen if i create entity manager inside the JTA transaction. But I have strong resons to create entity manager outside the transaction.

It is possible to call pulseTransactionCoordinator() in find() method as bellow?
Maybe in next version?

_ at Override
public <T> T find(Class<T> entityClass, Object primaryKey, LockModeType lockModeType, Map<String, Object> properties) {
checkOpen();
pulseTransactionCoordinator();
.............
_
Thank you,
Alex

( https://hibernate.atlassian.net/browse/HHH-14110#add-comment?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 ) Add Comment ( https://hibernate.atlassian.net/browse/HHH-14110#add-comment?atlOrigin=eyJpIjoiMmE4ZThlMzFmOTIwNDBhNTkyNmIwYTBkMzViNmMxYWEiLCJwIjoiaiJ9 )

Get Jira notifications on your phone! Download the Jira Cloud app for Android ( https://play.google.com/store/apps/details?id=com.atlassian.android.jira.core&referrer=utm_source%3DNotificationLink%26utm_medium%3DEmail ) or iOS ( https://itunes.apple.com/app/apple-store/id1006972087?pt=696495&ct=EmailNotificationLink&mt=8 ) This message was sent by Atlassian Jira (v1001.0.0-SNAPSHOT#100133- sha1:d093d11 )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-issues/attachments/20200717/86f0a9c4/attachment.html 


More information about the hibernate-issues mailing list