MyBatis调用存储过程,MyBatis调用函数的使用方法
一、MyBatis 调用存储过程
1、不带参数的
<select id="batchAnalyzeAll" statementType="CALLABLE" useCache="false">
call pro_rank_sum_all()
</select>
2、带参数的
<select id="batchAnalyzeByRoom" parameterType="int" statementType="CALLABLE" useCache="false">
call pro_rank_sum_room(#{room})
</select>
3、statementType 属性理解: STATEMENT,PREPARED 或 CALLABLE 中的一个。这会让 MyBatis 分别使用 Statement,PreparedStatement 或 CallableStatement,默认值:PREPARED。
4、useCache 属性理解: 将其设置为 true 后,将会导致本条语句的结果被二级缓存缓存起来,默认值:对 select 元素为 true。
二、MyBatis 调用函数
1、调用函数
<select id="toPinYin" parameterType="string" resultType="string">
SELECT to_pinyin(#{name}) from DUAL
</select>
1.1、补充: 该函数作用是,根据传入的中文字符转换为拼音 ,故输入、输出参数类型均为字符串。
参考资料:http://www.mybatis.org/mybatis-3/zh/index.html