码迷,mamicode.com
首页 > 其他好文 > 详细

MyBatis 调用存储过程

时间:2015-05-05 21:38:16      阅读:97      评论:0      收藏:0      [点我收藏+]

标签:

sqlxml,这里面的call 与后面不能换行;

<select id="getPersonCount" parameterMap="getPCMap"
        statementType="CALLABLE">
        CALL test.get_user_count(?,?)
    </select>
    <parameterMap type="java.util.Map" id="getPCMap">
        <parameter property="idtype" jdbcType="INTEGER" mode="IN" />
        <parameter property="usercount" jdbcType="INTEGER" mode="OUT" />
    </parameterMap>

 

test

statement = "PersonCondition.getPersonCount";
            Map<String, Integer> parameterMap = new HashMap<String, Integer>();
            parameterMap.put("idtype", 0);
            parameterMap.put("usercount", -1);

            sqlSession.selectOne(statement, parameterMap);
            
            Integer integer = parameterMap.get("usercount");
            System.out.println(integer);

procedure

BEGIN
IF id1=0 THEN
select count(*) from person where  id > 15 into count_id;
ELSE
select count(*) from person where  id < 15 into count_id;
end IF;
END

 

MyBatis 调用存储过程

标签:

原文地址:http://www.cnblogs.com/stono/p/4480040.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!