MYBATIS calls the oracle Stored Procedure

Source: Internet
Author: User

1. xml file

<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,
# {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. Methods in xxxmaper. Java

Object getgroupnum (paramspc PARAM );

4. Use demo

Sqlsession session = allsqlmap. getinstance (). opensession ();

Try {
Tbsysusermapper mapper = session. getmapper (tbsysusermapper. Class );
Paramspc Param = new paramspc ();
Param. setin_parameterid ("010401"); // fill in the in parameter. The out parameter does not need to be processed.
Param. setin_steelid ("65mn Rod Belt ");
Mapper. getgroupnum (PARAM );
System. out. println (param. getOUT_GN (); // obtain the calculation result.
System. out. println (param. getRST (). size ());

Session. commit (true );
} Catch (Exception e ){
E. printStackTrace ();
Session. rollback (true );
} Finally {
Session. close ();
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.