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.client.event.RowHandler;
19  import com.ibatis.sqlmap.engine.scope.StatementScope;
20  import com.ibatis.sqlmap.engine.transaction.Transaction;
21  
22  import java.sql.SQLException;
23  import java.util.List;
24  
25  /**
26   * The Class InsertStatement.
27   */
28  public class InsertStatement extends MappedStatement {
29  
30    /** The select key statement. */
31    private SelectKeyStatement selectKeyStatement;
32  
33    @Override
34    public StatementType getStatementType() {
35      return StatementType.INSERT;
36    }
37  
38    @Override
39    public Object executeQueryForObject(StatementScope statementScope, Transaction trans, Object parameterObject,
40        Object resultObject) throws SQLException {
41      throw new SQLException("Insert statements cannot be executed as a query.");
42    }
43  
44    @Override
45    public List executeQueryForList(StatementScope statementScope, Transaction trans, Object parameterObject,
46        int skipResults, int maxResults) throws SQLException {
47      throw new SQLException("Insert statements cannot be executed as a query.");
48    }
49  
50    @Override
51    public void executeQueryWithRowHandler(StatementScope statementScope, Transaction trans, Object parameterObject,
52        RowHandler rowHandler) throws SQLException {
53      throw new SQLException("Update statements cannot be executed as a query.");
54    }
55  
56    /**
57     * Gets the select key statement.
58     *
59     * @return the select key statement
60     */
61    public SelectKeyStatement getSelectKeyStatement() {
62      return selectKeyStatement;
63    }
64  
65    /**
66     * Sets the select key statement.
67     *
68     * @param selectKeyStatement
69     *          the new select key statement
70     */
71    public void setSelectKeyStatement(SelectKeyStatement selectKeyStatement) {
72      this.selectKeyStatement = selectKeyStatement;
73    }
74  }