ibatis调用存储过程

ibatis xml中
<!-- 调用存储过程来生成考生试卷 -->
	<parameterMap class="java.util.HashMap" id="examinee" >
		<parameter property="result" jdbcType="VARCHAR" javaType="java.lang.String" mode="OUT"/>  返回值如果是普通类型
		<parameter property="examinee_id" jdbcType="number" javaType="java.lang.Long" mode="IN"/>  
		<parameter property="paper_id" jdbcType="number" javaType="java.lang.Long" mode="IN"/>
	</parameterMap>
	
	<procedure id="createExamineePaper" parameterMap="examinee" resultClass="java.lang.String">
		<![CDATA[
      	{? = call func_gen_student_paper(?,?)}  //问号对应上面的parameterMap参数
   		]]>
	</procedure>


//如果返回值是map 则要写成
<parameter property="result" jdbcType="ORACLECURSOR" 
        javaType="java.util.HashMap" mode="OUT " resultMap="auditselect_resultList" />


//java中调用
public int createExamineePaper(Map map){
		this.queryForObject("Examinee.createExamineePaper", map);
		try{
			return (Integer)map.get("result");
		}catch(Exception e){
			new Throwable("调用存储过程未知错误!");
			return 9;
		}
	}

你可能感兴趣的:(java,xml,ibatis)