Mybatis 知识积累

官方网站

https://mybatis.org/mybatis-3/zh/index.html
https://mybatis.org/mybatis-3/getting-started.html
http://www.mybatis.cn/

mybatis-plugs
https://baomidou.com/

mybatis mapper 模板

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.mybatis.example.BlogMapper">
  <select id="selectBlog" resultType="Blog">
    select * from Blog where id = #{id}
  </select>
</mapper>

建议将 mybatis mapper 模版及 mybatis config 模版配置至idea中

mybatis foreach循环写法

select order_no ,order_type  from order_detail
where delete_date &gt;='2022-07-10' and delete_date &lt; '2022-07-14'
and order_type in (1,1108) and order_no in 
<foreach collection="orderNoList" separator="," open="(" close=")" index="" item="orderNo">
    #{orderNo,javaType=Integer}
</foreach>

mybatis 转义

mybatis 中 SQL 写在mapper.xml文件中,而xml解析 < 、>、<=、>= 时会出错,这时应该使用转义写法。

http://www.mybatis.cn/archives/754.html
posted @ 2022-07-16 14:05  crazy-zz5536  阅读(25)  评论(0编辑  收藏  举报