mybatis调用oracle存储过程例子.
1.MYBATIS方法:
<select id="getFlowNum" statementType="CALLABLE">
<![CDATA[
{call PRO_CFC_GETFLOWNUM(
#{V_IN_RANDOM,mode=IN,jdbcType=VARCHAR},
#{V_IN_BUSCODE,mode=IN,jdbcType=VARCHAR},
#{V_IN_REFRESHVAR,mode=IN,jdbcType=VARCHAR},
#{V_O_FLOWNUM,mode=OUT,jdbcType=INTEGER}
)}
]]>
</select>
2.MAPPER方法:
public interface TbcommonflownumMapper {
Integer getFlowNum(Map<String, Object> map);
}
3.SERVICE方法:
public Integer getFlowNum(String busCode, String refreshvar) {
synchronized (this) {
if(curnum!=null)curnum=null;
Map<String,Object> map = new HashMap<String, Object>();
map.put("V_IN_RANDOM", UUID.randomUUID().toString());//入参1 map的k值要和mybatis的变量名一致.
map.put("V_IN_BUSCODE", busCode); //入参2
map.put("V_IN_REFRESHVAR", refreshvar); //入参3
TbcommonflownumMapper.getFlowNum(map);
Object _curnum=map.get("V_O_FLOWNUM"); //过程出参值写在map里面.
if(_curnum==null)return null;
curnum=Integer.parseInt(_curnum.toString());
return curnum;
}
}