MyBatis嵌套查询column传多个参数描述
2016-05-04 21:58
295 查看
代码如下,红色部分为关键代码。
注意parameterType要为java.util.HashMap
<resultMap id="baseResultMap" type="Blog">
<association property="author" column="{id=author_id,likename=author_name}" javaType="Author" select="selectAuthor"/>
</resultMap>
<select id="selectAuthor" resultType="Author" parameterType="java.util.HashMap">
SELECT * FROM AUTHOR WHERE 1=1
<if test="id != null and id != '' ">
and ID = #{id}
</if>
<if test="likename != null and likename != '' ">
and name like CONCAT('%',#{likename},'%')
</if>
<if test="[b]author_id!= null and author_id!= '' ">[/b]
and id=#{[b]author_id}[/b]
</if>
</select>
注意parameterType要为java.util.HashMap
<resultMap id="baseResultMap" type="Blog">
<association property="author" column="{id=author_id,likename=author_name}" javaType="Author" select="selectAuthor"/>
</resultMap>
<select id="selectAuthor" resultType="Author" parameterType="java.util.HashMap">
SELECT * FROM AUTHOR WHERE 1=1
<if test="id != null and id != '' ">
and ID = #{id}
</if>
<if test="likename != null and likename != '' ">
and name like CONCAT('%',#{likename},'%')
</if>
<if test="[b]author_id!= null and author_id!= '' ">[/b]
and id=#{[b]author_id}[/b]
</if>
</select>
相关文章推荐
- 第三百九十一、二、三、四、五、六、七天 how can I 坚持
- “南通大学教务管理系统微信公众号” 用户体验分析
- Leetcode - Isomorphic Strings
- FFMPEG
- C#连接数据库的方法
- 模拟BootStrap的弹框功能
- 数据库建表时字段长度
- 19.Remove Nth Node From End of List(7.54%)
- 环信sdk与支付宝的冲突
- 【arduino】通过Esp8266-01模块实现的WiFi通信(3)使用TCP协议进行局域网通信(client篇)
- LeetCode---PowerOfTwo、PowerOfThree、 PowerOfFour解题分析
- 对MobSF的源码进行分析
- 百马百石
- for迭代求折纸超过珠峰高度
- Spark ZooKeeper数据恢复
- Java中的private、protected、public和default的区别
- [POJ1155]TELE(树形dp)
- android--线程池
- 使用Powershell注销指定用户
- Spring Web MVC实现Restful Web Service