一、IF语句
接口类(dao层)
接口类mapper.xml文件
测试
1.title为空时
2.author为空
3.都不为空
4.都为空
二、where
接口类(dao层)
接口类Mapper.xml
三、set
接口类(dao层)
接口类Mapper.xml
测试代码
执行结果
数据库信息
四、SQL片段使用
注意事项:
1.基于单表定义SQL片段
2.不要存在where标签
五、 Foreach
接口类(dao层)
mapper.xml文件
补充:
collection获得一个名字为ids的集合
之后结果类似:
for (Integer id:ids){ }
测试文件
执行结果