IBATIS调用存储过程

http://www.iteye.com/topic/84224

 

<parameterMap class="map" id="swapParameters">   
    <parameter property="namestr"  javaType="java.lang.String" jdbcType="varchar" mode="IN"/>   
    <parameter property="returnid"  javaType="java.lang.Integer" jdbcType="int" mode="OUT"/>   
</parameterMap>   
<procedure id="insertNameByProcedure" parameterMap="swapParameters">   
    {call UP_GETINSERTEDIDENTITY_TT(?,?)}    
</procedure>   

 

 

CREATE PROCEDURE `UP_GETINSERTEDIDENTITY_TT`(inname VARCHAR(20), OUT returnid INTEGER(11))    
    NOT DETERMINISTIC    
    SQL SECURITY INVOKER    
    COMMENT ''   
BEGIN   
     insert into `tt`(NAME) values(inname);    
     select LAST_INSERT_ID() into returnid ;    
END;  

 

Integer returnid = null;    
HashMap<String,Object> paramMap = new HashMap<String,Object>();    
paramMap.put("namestr", insertname);    
paramMap.put("returnid", returnid);    
this.getSqlMapClientTemplate().queryForObject("insertNameByProcedure", paramMap);    
return (Integer)paramMap.get("returnid"); 

 

你可能感兴趣的:(ibatis)