Results 1 to 3 of 3

Thread: Spring - Ibatis Stored Procedure Call

  1. #1
    Join Date
    Oct 2007
    Posts
    2

    Default 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

    Code:
    <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>
    
        <parameterMap id="test" class="map" >
           <parameter property="inputs" typeName="parameterTest"  />
           <parameter property="numRows" jdbcType="VARCHAR" javaType="java.lang.Long" mode="OUT"/>	 
        </parameterMap>
     
    	<procedure id="BUILD_CONTROL_INSERT" parameterMap="test" resultClass="java.lang.Long">
    	  {call BUILD_CONTROL_INSERT(?,?,?,?,?,?,?,?,?)}
    	</procedure>

  2. #2

    Default

    Hi,
    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.
    Gabriel Axel
    Sparklix | Blog | Twitter | Github

  3. #3
    Join Date
    Jul 2008
    Location
    Singapore
    Posts
    29

    Default

    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.

    Cheers,
    Winarto

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •