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

Driver exception when executing selectList on callable statement with output parmeters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0 Beta 10
    • 3.0 Beta 10
    • Core
    • None
    • Windows XP, Windows Server 2008, MS SQL Server 2008, jTDS driver v1.2.5

    Description

      MS SQL Server doesn't allow to fetch output parameter before all ResultSet objects and result counts aren't fully processed.

      As CallabeStatement javadoc says: "For maximum portability, a call's ResultSet objects and update counts should be processed prior to getting the values of output parameters."

      For example, I created simple mapping:

      <?xml version="1.0" encoding="UTF-8" ?>
      <!DOCTYPE mapper PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
      "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
      <mapper namespace="pl.azymut.zaminter.spz2">
      <resultMap id="getListResult" type="pl.azymut.zaminter.spz2.SomeObject">
      <result property="prop1" column="prop1"/>
      <result property="prop2" column="prop2"/>
      <result property="prop3" column="prop3"/>
      </resultMap>

      <select id="getList" parameterType="int" resultMap="getListResult" statementType="CALLABLE">
      {#

      {return,javaType=int,jdbcType=INTEGER,mode=OUT}

      = call spz.get_list #{param}}
      </select>
      </mapper>

      Executing
      List list = session.selectList("azymut.zaminter.spz2.getList", parameters);
      always throws exception with message "Output parameters have not yet been processed. Call getMoreResults()."

      I think changing method "query" in org.apache.ibatis.executor.statement.CallableStatementHandler class:

      public List query(Statement statement, ResultHandler resultHandler)
      throws SQLException

      { CallableStatement cs = (CallableStatement) statement; cs.execute(); resultSetHandler.handleOutputParameters(cs); return resultSetHandler.handleResultSets(cs); }

      into:

      public List query(Statement statement, ResultHandler resultHandler)
      throws SQLException

      { CallableStatement cs = (CallableStatement) statement; cs.execute(); List ret = resultSetHandler.handleResultSets(cs); resultSetHandler.handleOutputParameters(cs); return ret; }

      should resolve problem.

      Attachments

        Activity

          People

            cbegin Clinton Begin
            keiichi Adam Sikora
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: