Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-497

Bug when add two same length and hashCode SQLs to a batch executor

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 2.3.1
    • Core
    • None

    Description

      When I use batch execute, I found some SQL didn't execute sometime. I debuged and found a bug at com.ibatis.sqlmap.engine.execution.SqlExecutor$Batch.addBatch.
      When two SQL strings have same length and same hashCode ,this bug happens. Unfortunately, It happened to me . Does anybody believe that "B6" and "AU" have same hashCode? That is problem.

      the code :
      public void addBatch(RequestScope request, Connection conn, String sql, Object[] parameters) throws SQLException {
      PreparedStatement ps = null;
      if (currentSql != null && sql.hashCode() == currentSql.hashCode() && sql.length() == currentSql.length())

      { int last = statementList.size() - 1; ps = (PreparedStatement) statementList.get(last); }

      else

      { ps = conn.prepareStatement(sql); setStatementTimeout(request.getStatement(), ps); currentSql = sql; statementList.add(ps); batchResultList.add(new BatchResult(request.getStatement().getId(), sql)); }

      request.getParameterMap().setParameters(request, ps, parameters);
      ps.addBatch();
      size++;
      }

      Attachments

        Activity

          People

            jgbutler Jeff G. Butler
            richardwoo Dingguo Wu
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified