Search in sources :

Example 1 with JdbcMutation

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

the class NativeNonSelectQueryPlanImpl method executeUpdate.

@Override
public int executeUpdate(DomainQueryExecutionContext executionContext) {
    executionContext.getSession().autoFlushIfRequired(affectedTableNames);
    BulkOperationCleanupAction.schedule(executionContext.getSession(), affectedTableNames);
    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 JdbcMutation jdbcMutation = new NativeJdbcMutation(sql, jdbcParameterBinders, affectedTableNames);
    final JdbcMutationExecutor executor = StandardJdbcMutationExecutor.INSTANCE;
    final SharedSessionContractImplementor session = executionContext.getSession();
    // return jdbcServices.getJdbcMutationExecutor().execute(
    return executor.execute(jdbcMutation, jdbcParameterBindings, sql -> session.getJdbcCoordinator().getStatementPreparer().prepareStatement(sql), (integer, preparedStatement) -> {
    }, SqmJdbcExecutionContextAdapter.usingLockingAndPaging(executionContext));
}
Also used : NativeJdbcMutation(org.hibernate.sql.exec.spi.NativeJdbcMutation) NativeJdbcMutation(org.hibernate.sql.exec.spi.NativeJdbcMutation) JdbcMutation(org.hibernate.sql.exec.spi.JdbcMutation) JdbcParameterBindingsImpl(org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl) SharedSessionContractImplementor(org.hibernate.engine.spi.SharedSessionContractImplementor) QueryParameterBindings(org.hibernate.query.spi.QueryParameterBindings) JdbcParameterBinder(org.hibernate.sql.exec.spi.JdbcParameterBinder) JdbcParameterBindings(org.hibernate.sql.exec.spi.JdbcParameterBindings) JdbcMutationExecutor(org.hibernate.sql.exec.spi.JdbcMutationExecutor) StandardJdbcMutationExecutor(org.hibernate.sql.exec.internal.StandardJdbcMutationExecutor)

Aggregations

SharedSessionContractImplementor (org.hibernate.engine.spi.SharedSessionContractImplementor)1 QueryParameterBindings (org.hibernate.query.spi.QueryParameterBindings)1 JdbcParameterBindingsImpl (org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl)1 StandardJdbcMutationExecutor (org.hibernate.sql.exec.internal.StandardJdbcMutationExecutor)1 JdbcMutation (org.hibernate.sql.exec.spi.JdbcMutation)1 JdbcMutationExecutor (org.hibernate.sql.exec.spi.JdbcMutationExecutor)1 JdbcParameterBinder (org.hibernate.sql.exec.spi.JdbcParameterBinder)1 JdbcParameterBindings (org.hibernate.sql.exec.spi.JdbcParameterBindings)1 NativeJdbcMutation (org.hibernate.sql.exec.spi.NativeJdbcMutation)1