MYBATIS调用oracle存储过程2

1、xml文件

<select id="getGroupNum" statementType="CALLABLE" parameterType="com.guorui.model.ParamSPC">
{call GYL_COMMON.GETGROUPNUM(
#{IN_PARAMETERID,jdbcType=VARCHAR,mode=IN},
#{IN_STEELID,jdbcType=VARCHAR,mode=IN},null,null,null,
#{OUT_GN,jdbcType=INTEGER,mode=OUT},
#{RST,jdbcType=CURSOR,mode=OUT,resultMap=BaseResultMap2,javaType=java.sql.ResultSet})}
</select>

<resultMap id="BaseResultMap2" type="com.guorui.dao.TbSysUser">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Nov 15 19:49:43 CST 2010.
-->
<result column="USERID" jdbcType="DECIMAL" property="userid" />
<result column="NUSERID" jdbcType="VARCHAR" property="nuserid" />
<result column="STRUSERNAME" jdbcType="VARCHAR" property="strusername" />
<result column="STRDEP" jdbcType="VARCHAR" property="strdep" />
<result column="STRDUTY" jdbcType="VARCHAR" property="strduty" />
<result column="STRUSERPWD" jdbcType="VARCHAR" property="struserpwd" />
<result column="DTINSDATE" jdbcType="TIMESTAMP" property="dtinsdate" />
<result column="STRINSBY" jdbcType="VARCHAR" property="strinsby" />
<result column="DTUPTDATE" jdbcType="TIMESTAMP" property="dtuptdate" />
<result column="STRUPTBY" jdbcType="VARCHAR" property="struptby" />
<result column="LOGIN_COUNT" jdbcType="DECIMAL" property="loginCount" />
<result column="LOGIN_LAST_TIME" jdbcType="TIMESTAMP" property="loginLastTime" />
<result column="STATUS" jdbcType="VARCHAR" property="status" />
<result column="STRDEPNO" jdbcType="VARCHAR" property="strdepno" />
</resultMap>

2、parameter bean

public class ParamSPC {

String IN_PARAMETERID;
String IN_STEELID;
Integer OUT_GN;
List<TbSysUser> RST;

public String getIN_PARAMETERID() {
return IN_PARAMETERID;
}
public void setIN_PARAMETERID(String iN_PARAMETERID) {
IN_PARAMETERID = iN_PARAMETERID;
}
public String getIN_STEELID() {
return IN_STEELID;
}
public void setIN_STEELID(String iN_STEELID) {
IN_STEELID = iN_STEELID;
}
public Integer getOUT_GN() {
return OUT_GN;
}
public void setOUT_GN(Integer oUT_GN) {
OUT_GN = oUT_GN;
}
public List<TbSysUser> getRST() {
return RST;
}
public void setRST(List<TbSysUser> rST) {
RST = rST;
}

}

3、xxxMaper.java 中的方法

Object getGroupNum(ParamSPC param);

4、使用demo


SqlSession session = AllSqlMap.getInstance().openSession();

try {
TbSysUserMapper mapper = session.getMapper(TbSysUserMapper.class);
ParamSPC param = new ParamSPC();
param.setIN_PARAMETERID("010401"); // 填充 in 参数,out 参数不用任何处理
param.setIN_STEELID("65Mn棒带");
mapper.getGroupNum(param);
System.out.println(param.getOUT_GN()); // 获取计算结果
System.out.println(param.getRST().size());

session.commit(true);
} catch(Exception e){
e.printStackTrace();
session.rollback(true);
} finally {
session.close();
}

你可能感兴趣的:(oracle存储过程)