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

Batching of statements does not work for stored procedures

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.0
    • 2.3.1
    • Core
    • None
    • All relational databases

    Description

      iBatis SQLMaps incorporates a mechanism for utilizing the JDBC API's underlying batching capabilities (Statement.addBatch()) to efficiently group a set of database operations together for maximum performance. This mechanism works as expected for dynamic SQL, but does not work for callable statements.

      This behavior has been deduced using P6Spy (configured to log to a Log4j SocketAppender) in conjunction with the SQL Profiler tool. As a note - NOT all JDBC Drivers support batching of callable statements. Older DB2 type 4 drivers did not support batching of callable statements. However, most modern drivers do (e.g. Sybase jConnect, Oracle JDBC Driver etc)

      The fix for this issue is straightforward. Change the method definition for sqlExecuteUpdate in class com.ibatis.sqlmap.engine.mapping.statement.ProcedureStatement to be as follows:

      protected int sqlExecuteUpdate(RequestScope request, Connection conn, String sqlString, Object[] parameters) throws SQLException {

      if (request.getSession().isInBatch())

      { getSqlExecutor().addBatch(request, conn, sqlString, parameters); return 0; }

      else

      { return getSqlExecutor().executeUpdateProcedure(request, conn, sqlString.trim(), parameters); }

      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            brosnt Trevor Brosnan
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: