use of org.hibernate.sql.results.graph.AssemblerCreationState in project hibernate-orm by hibernate.
the class ResultsHelper method createRowReader.
public static <R> RowReader<R> createRowReader(ExecutionContext executionContext, LockOptions lockOptions, RowTransformer<R> rowTransformer, JdbcValues jdbcValues) {
final Map<NavigablePath, Initializer> initializerMap = new LinkedHashMap<>();
final List<Initializer> initializers = new ArrayList<>();
final SessionFactoryImplementor sessionFactory = executionContext.getSession().getFactory();
final List<DomainResultAssembler<?>> assemblers = jdbcValues.getValuesMapping().resolveAssemblers(new AssemblerCreationState() {
@Override
public LockMode determineEffectiveLockMode(String identificationVariable) {
return lockOptions.getEffectiveLockMode(identificationVariable);
}
@Override
public Initializer resolveInitializer(NavigablePath navigablePath, ModelPart fetchedModelPart, Supplier<Initializer> producer) {
final Initializer existing = initializerMap.get(navigablePath);
if (existing != null) {
if (fetchedModelPart.getNavigableRole().equals(existing.getInitializedPart().getNavigableRole())) {
ResultsLogger.LOGGER.tracef("Returning previously-registered initializer : %s", existing);
return existing;
}
}
final Initializer initializer = producer.get();
ResultsLogger.LOGGER.tracef("Registering initializer : %s", initializer);
initializerMap.put(navigablePath, initializer);
initializers.add(initializer);
return initializer;
}
@Override
public SqlAstCreationContext getSqlAstCreationContext() {
return sessionFactory;
}
});
logInitializers(initializerMap);
return new StandardRowReader<>(assemblers, initializers, rowTransformer);
}
Aggregations