use of org.hibernate.sql.results.jdbc.internal.DirectResultSetAccess in project hibernate-orm by hibernate.
the class OutputsImpl method extractResults.
protected List extractResults(ResultSet resultSet) {
final DirectResultSetAccess resultSetAccess = new DirectResultSetAccess(context.getSession(), jdbcStatement, resultSet);
final ProcedureCallImpl procedureCall = (ProcedureCallImpl) context;
final ResultSetMapping resultSetMapping = procedureCall.getResultSetMapping();
final JavaTypeRegistry javaTypeRegistry = context.getSession().getTypeConfiguration().getJavaTypeRegistry();
procedureCall.getParameterBindings().visitBindings((parameterImplementor, queryParameterBinding) -> {
ProcedureParameter parameter = (ProcedureParameter) parameterImplementor;
if (parameter.getMode() == ParameterMode.INOUT) {
final JavaType<?> basicType = javaTypeRegistry.getDescriptor(parameterImplementor.getParameterType());
if (basicType != null) {
resultSetMapping.addResultBuilder(new ScalarDomainResultBuilder<>(basicType));
} else {
throw new NotYetImplementedFor6Exception(getClass());
}
}
});
final ExecutionContext executionContext = new ExecutionContext() {
private final Callback callback = new CallbackImpl();
@Override
public SharedSessionContractImplementor getSession() {
return OutputsImpl.this.context.getSession();
}
@Override
public QueryOptions getQueryOptions() {
return new QueryOptionsAdapter() {
@Override
public Boolean isReadOnly() {
return false;
}
};
}
@Override
public String getQueryIdentifier(String sql) {
return sql;
}
@Override
public QueryParameterBindings getQueryParameterBindings() {
return QueryParameterBindings.NO_PARAM_BINDINGS;
}
@Override
public Callback getCallback() {
return callback;
}
};
final JdbcValues jdbcValues = new JdbcValuesResultSetImpl(resultSetAccess, null, null, this.context.getQueryOptions(), resultSetMapping.resolve(resultSetAccess, getSessionFactory()), null, executionContext);
final RowReader<Object[]> rowReader = (RowReader<Object[]>) ResultsHelper.createRowReader(executionContext, null, RowTransformerPassThruImpl.INSTANCE, jdbcValues);
/*
* Processing options effectively are only used for entity loading. Here we don't need these values.
*/
final JdbcValuesSourceProcessingOptions processingOptions = new JdbcValuesSourceProcessingOptions() {
@Override
public Object getEffectiveOptionalObject() {
return null;
}
@Override
public String getEffectiveOptionalEntityName() {
return null;
}
@Override
public Serializable getEffectiveOptionalId() {
return null;
}
@Override
public boolean shouldReturnProxies() {
return true;
}
};
final JdbcValuesSourceProcessingStateStandardImpl jdbcValuesSourceProcessingState = new JdbcValuesSourceProcessingStateStandardImpl(executionContext, processingOptions, executionContext::registerLoadingEntityEntry);
try {
final RowProcessingStateStandardImpl rowProcessingState = new RowProcessingStateStandardImpl(jdbcValuesSourceProcessingState, executionContext, rowReader, jdbcValues);
final List results = new ArrayList<>();
while (rowProcessingState.next()) {
results.add(rowReader.readRow(rowProcessingState, processingOptions));
rowProcessingState.finishRowProcessing();
}
return results;
} finally // catch (SQLException e) {
// throw context.getSession().getExceptionConverter().convert( e, "Error processing return rows" );
// }
{
rowReader.finishUp(jdbcValuesSourceProcessingState);
jdbcValuesSourceProcessingState.finishUp();
jdbcValues.finishUp(this.context.getSession());
}
}
Aggregations