hibernate/hibernate-orm — pull request #657 by karlvr (2014-01-14 10:10:12+00:00)
Title: HHH-8861 Session.refresh(instance) doesn't refresh the given "instance" object itself, if it was loaded in a batch

The issue is that the LegacyBatchingEntityLoader ignores the optionalObject et al parameters because they are not supported when loading batches. So a new entity is loaded during the refresh, rather than the existing entity / instance being refreshed.

We have made some small changes to support optionalObject when loading batches, and written two test cases to illustrate the issue and the fix.

There appears to be only one code path that needed to be skipped to support this, which is the shortcut obtaining of the EntityKey in EntityLoadQueryDetails. For that I have added a property to QueryParameters... that was a little bit more obvious a change than I was hoping for, but it felt like the right place, and it was necessary to distinguish between circumstances where the shortcut in EntityLoadQueryDetails was suitable.

https://hibernate.atlassian.net/browse/HHH-8861