View Javadoc
1   /**
2    *    Copyright 2009-2015 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    *       http://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 org.apache.ibatis.executor;
17  
18  import java.util.ArrayList;
19  import java.util.List;
20  
21  import org.apache.ibatis.mapping.MappedStatement;
22  
23  /**
24   * @author Jeff Butler
25   */
26  public class BatchResult {
27  
28    private final MappedStatement mappedStatement;
29    private final String sql;
30    private final List<Object> parameterObjects;
31  
32    private int[] updateCounts;
33  
34    public BatchResult(MappedStatement mappedStatement, String sql) {
35      super();
36      this.mappedStatement = mappedStatement;
37      this.sql = sql;
38      this.parameterObjects = new ArrayList<Object>();
39    }
40  
41    public BatchResult(MappedStatement mappedStatement, String sql, Object parameterObject) {
42      this(mappedStatement, sql);
43      addParameterObject(parameterObject);
44    }
45  
46    public MappedStatement getMappedStatement() {
47      return mappedStatement;
48    }
49  
50    public String getSql() {
51      return sql;
52    }
53  
54    @Deprecated
55    public Object getParameterObject() {
56      return parameterObjects.get(0);
57    }
58  
59    public List<Object> getParameterObjects() {
60      return parameterObjects;
61    }
62  
63    public int[] getUpdateCounts() {
64      return updateCounts;
65    }
66  
67    public void setUpdateCounts(int[] updateCounts) {
68      this.updateCounts = updateCounts;
69    }
70  
71    public void addParameterObject(Object parameterObject) {
72      this.parameterObjects.add(parameterObject);
73    }
74  
75  }