final ResultSetProcessingContext.EntityReferenceProcessingState processingState =
rootReturnReader.getIdentifierResolutionContext( context );
// if the entity reference we are hydrating is a Return, it is possible that its EntityKey is
// supplied by the QueryParameter optional entity information
if ( context.shouldUseOptionalEntityInformation() && context.getQueryParameters().getOptionalId() != null ) {
EntityKey entityKey = ResultSetProcessorHelper.getOptionalObjectKey(
context.getQueryParameters(),
context.getSession()
);
processingState.registerIdentifierHydratedForm( entityKey.getIdentifier() );
processingState.registerEntityKey( entityKey );
final EntityPersister entityPersister = processingState.getEntityReference().getEntityPersister();
if ( entityPersister.getIdentifierType().isComponentType() ) {
final ComponentType identifierType = (ComponentType) entityPersister.getIdentifierType();
if ( !identifierType.isEmbedded() ) {
addKeyManyToOnesToSession(
context,
identifierType,
entityKey.getIdentifier()
);
}
}
}
return super.readRow( resultSet, context );