View Javadoc
1   /*
2    *    Copyright 2009-2023 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 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      this.mappedStatement = mappedStatement;
36      this.sql = sql;
37      this.parameterObjects = new ArrayList<>();
38    }
39  
40    public BatchResult(MappedStatement mappedStatement, String sql, Object parameterObject) {
41      this(mappedStatement, sql);
42      addParameterObject(parameterObject);
43    }
44  
45    public MappedStatement getMappedStatement() {
46      return mappedStatement;
47    }
48  
49    public String getSql() {
50      return sql;
51    }
52  
53    @Deprecated
54    public Object getParameterObject() {
55      return parameterObjects.get(0);
56    }
57  
58    public List<Object> getParameterObjects() {
59      return parameterObjects;
60    }
61  
62    public int[] getUpdateCounts() {
63      return updateCounts;
64    }
65  
66    public void setUpdateCounts(int[] updateCounts) {
67      this.updateCounts = updateCounts;
68    }
69  
70    public void addParameterObject(Object parameterObject) {
71      this.parameterObjects.add(parameterObject);
72    }
73  
74  }