概要
1.读者在阅读博客前可以事先阅读MyBatis3.4官方文档
2.本篇博客用于解决在使用MyBatis3.4时可能出现的困惑
choose标签
1.先看一段MyBatis3.4官方文档的例子
<select id="findActiveBlogLike" resultType="Blog">
SELECT * FROM BLOG WHERE state = ‘ACTIVE’
<choose>
<when test="title != null">
AND title like #{title}
</when>
<when test="author != null and author.name != null">
AND author_name like #{author.name}
</when>
<otherwise>
AND featured = 1
</otherwise>
</choose>
</select>
2.choose标签在使用时等价于java中的if else
if(...){
...
}else if(...){
...
}else{
...
}
参考文档
http://blog.csdn.net/ABCD898989/article/category/6076264
http://blog.csdn.net/abcd898989/article/details/51222452