When batch fetching is enabled, refreshing an entity with a lock request seems to do two things incorrectly:
The lock mode does not seem to be set/retained correctly (related to but this is not the same issue).
See HibernateTests.testLazyCollectionAfterBatchFetchRefreshLock in the attached project.
Note that even if the current assertion failure is resolved in the above test, will still cause this test to fail due to the exception thrown by delazifying the children; I'm aware that issue is still open.
When other entities are retrieved in the refresh, inspection of the SQL generated shows that multiple records are locked. It seems to me that when requesting a lock for a specific entity (even if batch fetching is enabled) only a single entity should be locked.
I have attached the test project that illustrates the above issues. You can also find it on github at https://github.com/caspianb/HibernateRefreshTest
The first issue looks to have been fixed in 5.3.8 as well. Looking through the updated patch notes, it looks like was logged against the exact same scenario.
Should I update the JIRA to reference just the refresh issue mentioned in the second bullet point?
, yes, please do update the issue to cover just the remaining issue.