MyBatis调用存储过程,MyBatis调用函数的使用方法

               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

MySQL触发器资料整理创建触发器及查看、删除触发器

MySQL存储过程学习整理,游标使用,参数输入输出

 MyBatis调用存储过程,MyBatis调用函数的使用方法

MySQL 创建函数, MySQL定义函数实现汉字转拼音 MySQL汉字转拼音MySQL汉字生成拼音字符串

发布了156 篇原创文章 · 获赞 159 · 访问量 49万+

猜你喜欢

转载自blog.csdn.net/HaHa_Sir/article/details/100068912
今日推荐