SessionFactoryImplementor factory) {
this.loadPlan = loadPlan;
final SelectStatementBuilder select = new SelectStatementBuilder( factory.getDialect() );
final EntityReturn rootReturn = Helper.INSTANCE.extractRootReturn( loadPlan, EntityReturn.class );
final AliasResolutionContext aliasResolutionContext = new AliasResolutionContextImpl( factory );
final ReaderCollectorImpl readerCollector = new ReaderCollectorImpl();
final String[] keyColumnNamesToUse = keyColumnNames != null
? keyColumnNames
: ( (Queryable) rootReturn.getEntityPersister() ).getIdentifierColumnNames();
// apply root entity return specifics
applyRootReturnSpecifics(
select,
keyColumnNamesToUse,
rootReturn,
factory,
buildingParameters,
aliasResolutionContext
);
readerCollector.addReader(
new EntityReturnReader(
rootReturn,
aliasResolutionContext.resolveAliases( rootReturn ),
new EntityIdentifierReaderImpl(
rootReturn,
aliasResolutionContext.resolveAliases( rootReturn ),
Collections.<EntityReferenceReader>emptyList()
)
)
);