Skip to main content

MyBatis

David LiuLess than 1 minute

MyBatis

动态SQL

缓存

逆向工程

DML不需要写resultType

resultType:表的每一行的数据的类型

动态SQL

静态SQL:结构恒定的,虽然可以传入参数,但是结构不会变

动态SQL:语句的结构会变化,如批量添加、批量删除,可以通过循环标签

foreach 标签

INSTERT INTO t_student(name, age, major, birthdate)
VALUES
<foreach collection="list" item="stu" separator=",">
	(#{stu.name},#{stu.age},#{stu.major},#{stu.birthdate})
</foreach>

delete FROM t_student
WHERE id IN
<foreach collection="list" item="id" separator="," open="(" close=")">
	#{id}
</foreach>