public void printBatchResults(List<BatchResult> results) { if (results.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append("Batch summary:\n"); for (int i = 0; i < results.size(); i++) { BatchResult result = results.get(i); sb.append("Result ").append(i).append(":\t"); sb.append(result.getSql().replaceAll("\n", "").replaceAll("\\s+", " ")).append("\t"); sb.append("Update counts: ").append(Arrays.toString(result.getUpdateCounts())).append("\n"); } logDebug("082", sb.toString()); } }
/** * Returns the statement id of the statement that caused the failure * * @return the statement id */ public String getFailingStatementId() { return batchResult.getMappedStatement().getId(); } }
public BatchResult(MappedStatement mappedStatement, String sql, Object parameterObject) { this(mappedStatement, sql); addParameterObject(parameterObject); }
BatchResult batchResult = batchResultList.get(i); try { batchResult.setUpdateCounts(stmt.executeBatch()); MappedStatement ms = batchResult.getMappedStatement(); List<Object> parameterObjects = batchResult.getParameterObjects(); KeyGenerator keyGenerator = ms.getKeyGenerator(); if (Jdbc3KeyGenerator.class.equals(keyGenerator.getClass())) { message.append(batchResult.getMappedStatement().getId()) .append(" (batch index #") .append(i + 1)
BatchResult batchResult = batchResultList.get(i); try { batchResult.setUpdateCounts(stmt.executeBatch()); MappedStatement ms = batchResult.getMappedStatement(); Object parameter = batchResult.getParameterObject(); KeyGenerator keyGenerator = ms.getKeyGenerator(); if (keyGenerator instanceof Jdbc3KeyGenerator) { message.append(batchResult.getMappedStatement().getId()) .append(" (batch index #") .append(i + 1)
@Override public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException { final Configuration configuration = ms.getConfiguration(); final StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null, null); final BoundSql boundSql = handler.getBoundSql(); final String sql = boundSql.getSql(); final Statement stmt; if (sql.equals(currentSql) && ms.equals(currentStatement)) { int last = statementList.size() - 1; stmt = statementList.get(last); applyTransactionTimeout(stmt); handler.parameterize(stmt);//fix Issues 322 BatchResult batchResult = batchResultList.get(last); batchResult.addParameterObject(parameterObject); } else { Connection connection = getConnection(ms.getStatementLog()); stmt = handler.prepare(connection, transaction.getTimeout()); handler.parameterize(stmt); //fix Issues 322 currentSql = sql; currentStatement = ms; statementList.add(stmt); batchResultList.add(new BatchResult(ms, sql, parameterObject)); } // handler.parameterize(stmt); handler.batch(stmt); return BATCH_UPDATE_RETURN_VALUE; }
/** * Returns the SQL statement that caused the failure * (not the parameterArray) * * @return the failing SQL string */ public String getFailingSqlStatement() { return batchResult.getSql(); }
public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException { Configuration configuration = ms.getConfiguration(); StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null); BoundSql boundSql = handler.getBoundSql(); String sql = boundSql.getSql(); Statement stmt; if (currentSql != null && sql.hashCode() == currentSql.hashCode() && sql.length() == currentSql.length()) { int last = statementList.size() - 1; stmt = statementList.get(last); } else { Connection connection = transaction.getConnection(); stmt = handler.prepare(connection); currentSql = sql; statementList.add(stmt); batchResultList.add(new BatchResult(ms, sql, parameterObject)); } handler.parameterize(stmt); handler.batch(stmt); return BATCH_UPDATE_RETURN_VALUE; }
for (int statementResult : batchResult.getUpdateCounts()) { flushResultSize++; DbOperation thisOperation = operationIt.next();
BatchResult batchResult = batchResultList.get(i); try { batchResult.setUpdateCounts(stmt.executeBatch()); MappedStatement ms = batchResult.getMappedStatement(); List<Object> parameterObjects = batchResult.getParameterObjects(); KeyGenerator keyGenerator = ms.getKeyGenerator(); if (Jdbc3KeyGenerator.class.equals(keyGenerator.getClass())) { } catch (BatchUpdateException e) { StringBuilder message = new StringBuilder(); message.append(batchResult.getMappedStatement().getId()) .append(" (batch index #") .append(i + 1)
@Override public int doUpdate(MappedStatement ms, Object parameterObject) throws SQLException { final Configuration configuration = ms.getConfiguration(); final StatementHandler handler = configuration.newStatementHandler(this, ms, parameterObject, RowBounds.DEFAULT, null, null); final BoundSql boundSql = handler.getBoundSql(); final String sql = boundSql.getSql(); final Statement stmt; if (sql.equals(currentSql) && ms.equals(currentStatement)) { int last = statementList.size() - 1; stmt = statementList.get(last); applyTransactionTimeout(stmt); handler.parameterize(stmt);//fix Issues 322 BatchResult batchResult = batchResultList.get(last); batchResult.addParameterObject(parameterObject); } else { Connection connection = getConnection(ms.getStatementLog()); stmt = handler.prepare(connection, transaction.getTimeout()); handler.parameterize(stmt); //fix Issues 322 currentSql = sql; currentStatement = ms; statementList.add(stmt); batchResultList.add(new BatchResult(ms, sql, parameterObject)); } handler.batch(stmt); return BATCH_UPDATE_RETURN_VALUE; }
public String getFailingSqlStatement() { return batchResult.getSql(); }
for (int statementResult : batchResult.getUpdateCounts()) { flushResultSize++; DbOperation thisOperation = operationIt.next();
public void printBatchResults(List<BatchResult> results) { if (results.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append("Batch summary:\n"); for (int i = 0; i < results.size(); i++) { BatchResult result = results.get(i); sb.append("Result ").append(i).append(":\t"); sb.append(result.getSql().replaceAll("\n", "").replaceAll("\\s+", " ")).append("\t"); sb.append("Update counts: ").append(Arrays.toString(result.getUpdateCounts())).append("\n"); } logDebug("082", sb.toString()); } }
/** * Returns the SQL statement that caused the failure * (not the parameterArray) * * @return the failing SQL string */ public String getFailingSqlStatement() { return batchResult.getSql(); }
public String getFailingStatementId() { return batchResult.getMappedStatement().getId(); } }
for (int statementResult : batchResult.getUpdateCounts()) { flushResultSize++; DbOperation thisOperation = operationIt.next();
public BatchResult(MappedStatement mappedStatement, String sql, Object parameterObject) { this(mappedStatement, sql); addParameterObject(parameterObject); }
public void printBatchResults(List<BatchResult> results) { if (results.size() > 0) { StringBuilder sb = new StringBuilder(); sb.append("Batch summary:\n"); for (int i = 0; i < results.size(); i++) { BatchResult result = results.get(i); sb.append("Result ").append(i).append(":\t"); sb.append(result.getSql().replaceAll("\n", "").replaceAll("\\s+", " ")).append("\t"); sb.append("Update counts: ").append(Arrays.toString(result.getUpdateCounts())).append("\n"); } logDebug("082", sb.toString()); } }
/** * Returns the statement id of the statement that caused the failure * * @return the statement id */ public String getFailingStatementId() { return batchResult.getMappedStatement().getId(); } }