1. 小于号这些字符在MyBatis的使用
在xml中 小于号,大于号 这些字符与 xml字符冲突。为了不冲突只能用其他的字符表示这些小于,大于号
注意必须加分号结束
例子
<select id="findByFatherId" parameterType="int" resultType="UmsRoleMenu">
select * from ums_role_menu where father_id = #{father_id} and level < 3
</select>
2. 存储过程的调用
2.1 无返回参数
存储过程 - MYSQL
CREATE DEFINER=`skip-grants user`@`skip-grants host` PROCEDURE `getUserMenuList`(IN `user_id` int)
BEGIN
#Routine body goes here...
DECLARE g_menuIds VARCHAR(100);
select menuIds into g_menuIds from ums_user_role where id in (select role_id from ums_user where id = user_id);
select * from ums_role_menu where id in (
select SUBSTRING_INDEX(SUBSTRING_INDEX(g_menuIds,',',help_topic_id+1),',',-1) as num
FROM mysql.help_topic
where help_topic_id < (LENGTH(g_menuIds) - LENGTH(REPLACE(g_menuIds,',','')) + 1)
);
END
映射文件 - MyBatis
<select id="findAll2" resultType="UmsRoleMenu" parameterType="int">
{
call getUserMenuList(#{user_id})
}
</select>