简体   繁体   中英

Return null from procedure in MyBatis

I can't get the value back from procedure. It does an insert on a table and must return a code. The data is insert correctly, but the code returned is always null.

<parameterMap id="callParameters" type="Call" >
   <parameter property="client" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="originalAnalyst" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="currentAnalyst" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="analystType" jdbcType="INTEGER" mode="IN"/>
   <parameter property="category" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="product" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="process" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="problem" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="priority" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="status" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="serviceType" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="abstract" jdbcType="VARCHAR"  mode="IN" />
   <parameter property="descript" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="nullField" jdbcType="VARCHAR"  mode="IN"/>
   <parameter property="returnField" jdbcType="VARCHAR"  mode="OUT"/>
   <parameter property="callNumber" jdbcType="VARCHAR"  mode="OUT" />
   <parameter property="currentDate" jdbcType="TIMESTAMP" mode="IN"  />
   <parameter property="constant1" jdbcType="INTEGER" mode="IN"/>
   <parameter property="constant0" jdbcType="INTEGER" mode="IN"/>
</parameterMap>
<select id="open-call"  parameterMap="callParameters" resultType="Call"  statementType="CALLABLE">
   {call ADMAHD30.spr_AutoReq(#{returnField},#{constant1},#{callNumber},#{currentDate},#{client},#{originalAnalyst},#{currentAnalyst},#{analystType},#{category},#{product},#{process},#{problem},#{nullField},#{priority},#{status},#{serviceType},#{abstract},#{descript},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{nullField},#{constant0})}
 </select>

All this attributes are mappend in my object correctly. Is there something wrong?

I'm a bit rusty on myBatis, but if you're expecting a String back, why isn't the resultType "java.lang.String"?

Edit: What about using a resultMap instead of resultType (assuming the sp has specified a name for the return params):

<resultMap id="CallResultMap" type="com...Call">
        <result property="callNumber" column="callNumberCol"/>
        <result property="returnField" column="returnFieldCol"/>
</resultMap>

and then include the result parameter in your parameterMap.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM