Announcement Announcement Module
No announcement yet.
Spring - Ibatis Stored Procedure Call Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring - Ibatis Stored Procedure Call

    I have an Oracle stored procedure that inserts a row into a table from a set of input parameters and returns a number back.

    I want to map the input parameters to a Java object and return the output parameter as Integer.

    I am not able to achieve this since the Ibatis Paramerter Map always expects a Map or a custom java object and not both.

    Is it possible to achieve this? I have attached the Ibatis config below

    <parameterMap  id="parameterTest" class="com.fmrco.compliance.ace.builder.control.BuildControlObject" >	  
    	    <parameter property="buildRunId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="ruleKeyId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="ruleVerNum" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="dataLoadId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="buildTypeRefId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="buildStatusRefId" jdbcType="NUMBER" javaType="java.lang.Long" mode="IN"/>
    	    <parameter property="buildComment" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>
    	    <parameter property="addUsrId" jdbcType="VARCHAR" javaType="java.lang.String" mode="IN"/>	   
        <parameterMap id="test" class="map" >
           <parameter property="inputs" typeName="parameterTest"  />
           <parameter property="numRows" jdbcType="VARCHAR" javaType="java.lang.Long" mode="OUT"/>	 
    	<procedure id="BUILD_CONTROL_INSERT" parameterMap="test" resultClass="java.lang.Long">
    	  {call BUILD_CONTROL_INSERT(?,?,?,?,?,?,?,?,?)}

  • #2
    I don't think that's possible, at least according to any example I've seen. The "cleanest" solution I can suggest is to use Apache Commons BeanUtils to copy your domain object properties to a map and after calling the procedure copying the desired value from the map to another variable - three lines instead of one is not that terrible.
    If anyone can suggest a better way I'd also like to hear it.


    • #3
      Hi busybee,

      I don't understand what your intention is, however based on your ibatis config, I believe it won't work because the number of parameter in the parameterMap is not the same as the number of ? in your stored procedure.

      If you really need a custom converter, you can consider to implement TypeHandlerCallback interface.

      Hope it can help.