HHH-8861 Session.refresh(instance) doesn't update given instance if it was loaded in a batch

When loading a batch, if we've been passed an optional object, then use it and populate that optional object with the row from the batch matching the entity's id.

We have to bypass the shortcut in EntityLoadQueryDetails, where it determines the entity key early if we're using an optional object, as we instead need to determine the entityKey from the result set row and then only use the optionalObject if the entity keys match.