Search in sources :

Example 6 with JdbcParameterBinder

use of org.hibernate.sql.exec.spi.JdbcParameterBinder in project hibernate-orm by hibernate.

the class NativeSelectQueryPlanImpl method performScroll.

@Override
public ScrollableResultsImplementor<R> performScroll(ScrollMode scrollMode, DomainQueryExecutionContext executionContext) {
    if (executionContext.getQueryOptions().getEffectiveLimit().getMaxRowsJpa() == 0) {
        return EmptyScrollableResults.INSTANCE;
    }
    final List<JdbcParameterBinder> jdbcParameterBinders;
    final JdbcParameterBindings jdbcParameterBindings;
    final QueryParameterBindings queryParameterBindings = executionContext.getQueryParameterBindings();
    if (parameterList == null || parameterList.isEmpty()) {
        jdbcParameterBinders = Collections.emptyList();
        jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS;
    } else {
        jdbcParameterBinders = new ArrayList<>(parameterList.size());
        jdbcParameterBindings = new JdbcParameterBindingsImpl(parameterList.size());
        jdbcParameterBindings.registerNativeQueryParameters(queryParameterBindings, parameterList, jdbcParameterBinders, executionContext.getSession().getFactory());
    }
    final JdbcSelect jdbcSelect = new JdbcSelect(sql, jdbcParameterBinders, resultSetMapping, affectedTableNames, Collections.emptySet());
    final JdbcSelectExecutor executor = JdbcSelectExecutorStandardImpl.INSTANCE;
    // return jdbcServices.getJdbcSelectExecutor().scroll(
    return executor.scroll(jdbcSelect, scrollMode, jdbcParameterBindings, SqmJdbcExecutionContextAdapter.usingLockingAndPaging(executionContext), null);
}
Also used : JdbcSelect(org.hibernate.sql.exec.spi.JdbcSelect) JdbcParameterBindingsImpl(org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl) QueryParameterBindings(org.hibernate.query.spi.QueryParameterBindings) JdbcParameterBinder(org.hibernate.sql.exec.spi.JdbcParameterBinder) JdbcSelectExecutor(org.hibernate.sql.exec.spi.JdbcSelectExecutor) JdbcParameterBindings(org.hibernate.sql.exec.spi.JdbcParameterBindings)

Example 7 with JdbcParameterBinder

use of org.hibernate.sql.exec.spi.JdbcParameterBinder in project hibernate-orm by hibernate.

the class NativeSelectQueryPlanImpl method performList.

@Override
public List<R> performList(DomainQueryExecutionContext executionContext) {
    if (executionContext.getQueryOptions().getEffectiveLimit().getMaxRowsJpa() == 0) {
        return Collections.emptyList();
    }
    final List<JdbcParameterBinder> jdbcParameterBinders;
    final JdbcParameterBindings jdbcParameterBindings;
    final QueryParameterBindings queryParameterBindings = executionContext.getQueryParameterBindings();
    if (parameterList == null || parameterList.isEmpty()) {
        jdbcParameterBinders = Collections.emptyList();
        jdbcParameterBindings = JdbcParameterBindings.NO_BINDINGS;
    } else {
        jdbcParameterBinders = new ArrayList<>(parameterList.size());
        jdbcParameterBindings = new JdbcParameterBindingsImpl(parameterList.size());
        jdbcParameterBindings.registerNativeQueryParameters(queryParameterBindings, parameterList, jdbcParameterBinders, executionContext.getSession().getFactory());
    }
    executionContext.getSession().autoFlushIfRequired(affectedTableNames);
    final JdbcSelect jdbcSelect = new JdbcSelect(sql, jdbcParameterBinders, resultSetMapping, affectedTableNames, Collections.emptySet());
    final JdbcSelectExecutor executor = JdbcSelectExecutorStandardImpl.INSTANCE;
    // return jdbcServices.getJdbcSelectExecutor().execute(
    return executor.list(jdbcSelect, jdbcParameterBindings, SqmJdbcExecutionContextAdapter.usingLockingAndPaging(executionContext), null, ListResultsConsumer.UniqueSemantic.NONE);
}
Also used : JdbcSelect(org.hibernate.sql.exec.spi.JdbcSelect) JdbcParameterBindingsImpl(org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl) QueryParameterBindings(org.hibernate.query.spi.QueryParameterBindings) JdbcParameterBinder(org.hibernate.sql.exec.spi.JdbcParameterBinder) JdbcSelectExecutor(org.hibernate.sql.exec.spi.JdbcSelectExecutor) JdbcParameterBindings(org.hibernate.sql.exec.spi.JdbcParameterBindings)

Aggregations

JdbcParameterBinder (org.hibernate.sql.exec.spi.JdbcParameterBinder)7 JdbcParameterBindingsImpl (org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl)4 JdbcParameterBindings (org.hibernate.sql.exec.spi.JdbcParameterBindings)4 SQLException (java.sql.SQLException)3 QueryParameterBindings (org.hibernate.query.spi.QueryParameterBindings)3 SharedSessionContractImplementor (org.hibernate.engine.spi.SharedSessionContractImplementor)2 QueryOptions (org.hibernate.query.spi.QueryOptions)2 LogicalConnectionImplementor (org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor)2 JdbcCallRefCursorExtractorImpl (org.hibernate.sql.exec.internal.JdbcCallRefCursorExtractorImpl)2 JdbcSelect (org.hibernate.sql.exec.spi.JdbcSelect)2 JdbcSelectExecutor (org.hibernate.sql.exec.spi.JdbcSelectExecutor)2 CallableStatement (java.sql.CallableStatement)1 PreparedStatement (java.sql.PreparedStatement)1 ArrayList (java.util.ArrayList)1 IdentityHashMap (java.util.IdentityHashMap)1 Map (java.util.Map)1 JdbcServices (org.hibernate.engine.jdbc.spi.JdbcServices)1 SessionEventListenerManager (org.hibernate.engine.spi.SessionEventListenerManager)1 JdbcMapping (org.hibernate.metamodel.mapping.JdbcMapping)1 CallableStatementSupport (org.hibernate.procedure.spi.CallableStatementSupport)1