【MyBatis】动态 SQL
2024-09-01 22:29:03
【MyBatis】动态 SQL
转载:
目录
==========================================
1、if
2、choose when otherwise
3、trim where set
4、foreach
5、bind
==========================================
1、if
<select id="selectAuthor" resultType="Author">
select * from author where sex = 'male'
<if test="name != null">
and name = #{name}
</if>
</select>
5、bind
基本参数
public List<Blog> selectBlogList(@Param("title") String title);
<select id="selectBlogList" resultType="Blog">
<bind name="titlePattern" value="'%' + title + '%'"/>
select * from blog
<where>
<if test="title != null">
and title like #{titlePattern}
</if>
</where>
</select>
对象参数
public List<Blog> selectBlogList(Blog blog);
<select id="selectBlogList" resultType="Blog">
<bind name="titlePattern" value="'%' + _parameter.getTitle() + '%'"/>
select * from blog
<where>
<if test="title != null">
and title like #{titlePattern}
</if>
</where>
</select>
最新文章
- Head First设计模式之策略模式(Strategy Pattern)
- linux系统性能调优第一步——性能分析(vmstat)
- POJ 3565 Ants (最小权匹配)
- MT4平台上mql4实现的基于macd指标的智能交易EA
- 小学生玩ACM----广搜
- 8 个实用的 Linux netcat 命令示例
- Selenium Webdriver firefox 浏览器问题
- sqlserver 操作xml
- HDU 2489 Minimal Ratio Tree 最小生成树+DFS
- Hadoop(八)Java程序访问HDFS集群中数据块与查看文件系统
- ubuntu下安装无界面浏览器
- CentOS 7从Python 2.7升级至Python3.6.1
- 我们为什么要学习 Spring Boot
- 解决Win10 Virtualbox5.2.18桥接不能联网小记
- Mini-Batch 、Momentum、Adam算法的实现
- windows下安装mingw-w64
- 再读c++primer plus 001
- yield学习
- 同台服务器 部署多个tomcat 需要做的修改
- 【树状数组】【P2345】 奶牛集会