View Javadoc
1   /*
2    * Copyright 2004-2022 the original author or authors.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package com.ibatis.sqlmap.engine.mapping.statement;
17  
18  import com.ibatis.sqlmap.engine.scope.StatementScope;
19  
20  import java.sql.Connection;
21  import java.sql.SQLException;
22  
23  /**
24   * The Class ProcedureStatement.
25   */
26  public class ProcedureStatement extends MappedStatement {
27  
28    @Override
29    protected void postProcessParameterObject(StatementScope statementScope, Object parameterObject,
30        Object[] parameters) {
31      statementScope.getParameterMap().refreshParameterObjectValues(statementScope, parameterObject, parameters);
32    }
33  
34    @Override
35    protected int sqlExecuteUpdate(StatementScope statementScope, Connection conn, String sqlString, Object[] parameters)
36        throws SQLException {
37      if (statementScope.getSession().isInBatch()) {
38        getSqlExecutor().addBatch(statementScope, conn, sqlString, parameters);
39        return 0;
40      } else {
41        return getSqlExecutor().executeUpdateProcedure(statementScope, conn, sqlString.trim(), parameters);
42      }
43    }
44  
45    @Override
46    protected void sqlExecuteQuery(StatementScope statementScope, Connection conn, String sqlString, Object[] parameters,
47        int skipResults, int maxResults, RowHandlerCallback callback) throws SQLException {
48      getSqlExecutor().executeQueryProcedure(statementScope, conn, sqlString.trim(), parameters, skipResults, maxResults,
49          callback);
50    }
51  
52    @Override
53    public StatementType getStatementType() {
54      return StatementType.PROCEDURE;
55    }
56  }