In SessionImpl.doFlush the call to checkTransactionNeededForUpdateOperation will throw an exception TransactionRequiredException if the session was opened before a transaction started, and no other major session methods have been called yet (in case of a JTA setup).
This is because the TransactionCoordinator returns false on isTransactionActive when isJoined is false.
In most other major session methods a call to pulseTransactionCoordinator is done which would auto join an available transaction. This is also done in doFlush but only after the call to checkTransactionNeededForUpdateOperation.
If these calls would be switched around the session would join the active transaction and doFlush would succeed successfully.
I don't know how long this issue existed, but at least since 5.4.12
I hate to nag, but any word on accepting this patch?
It is blocking our effort to upgrade to hibernate 5 and our release deadline is approaching.
Backported to branch 5.3 as well.