BatchResult.java

  1. /*
  2.  *    Copyright 2009-2021 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. import java.util.ArrayList;
  18. import java.util.List;

  19. import org.apache.ibatis.mapping.MappedStatement;

  20. /**
  21.  * @author Jeff Butler
  22.  */
  23. public class BatchResult {

  24.   private final MappedStatement mappedStatement;
  25.   private final String sql;
  26.   private final List<Object> parameterObjects;

  27.   private int[] updateCounts;

  28.   public BatchResult(MappedStatement mappedStatement, String sql) {
  29.     super();
  30.     this.mappedStatement = mappedStatement;
  31.     this.sql = sql;
  32.     this.parameterObjects = new ArrayList<>();
  33.   }

  34.   public BatchResult(MappedStatement mappedStatement, String sql, Object parameterObject) {
  35.     this(mappedStatement, sql);
  36.     addParameterObject(parameterObject);
  37.   }

  38.   public MappedStatement getMappedStatement() {
  39.     return mappedStatement;
  40.   }

  41.   public String getSql() {
  42.     return sql;
  43.   }

  44.   @Deprecated
  45.   public Object getParameterObject() {
  46.     return parameterObjects.get(0);
  47.   }

  48.   public List<Object> getParameterObjects() {
  49.     return parameterObjects;
  50.   }

  51.   public int[] getUpdateCounts() {
  52.     return updateCounts;
  53.   }

  54.   public void setUpdateCounts(int[] updateCounts) {
  55.     this.updateCounts = updateCounts;
  56.   }

  57.   public void addParameterObject(Object parameterObject) {
  58.     this.parameterObjects.add(parameterObject);
  59.   }

  60. }