Python 官方文档:入门教程 => 点击学习
单个参数直接传即可,多参数传递如下 <resultMap id="stationVo" type="com.gt.dev.domain.vo.DevStationVO" ext
单个参数直接传即可,多参数传递如下
<resultMap id="stationVo" type="com.gt.dev.domain.vo.DevStationVO" extends="station">
<result property="distance" column="distance"/>
<association property="on" column="{stationId=id,state=on}"
select="com.gt.dev.mapper.DevInfoMapper.countByStationId"/>
<association property="off" column="{stationId=id,state=off}"
select="com.gt.dev.mapper.DevInfoMapper.countByStationId"/>
<association property="error" column="{stationId=id,state=error}"
select="com.gt.dev.mapper.DevInfoMapper.countByStationId"/>
</resultMap>
mybatis联表查询的时候我们会用到association标签
一个参数的时候:
<association column="id" property="User" select="getUser"></association>
<select id="getUser" resultMap="UserMap" parameterType="java.lang.String">
SELECT * FROM user_table WHERE id = #{id}
</select>
那多个参数的时候怎么搞呢,今天就遇到这个场景,记录一下:
association标签里面的column以对象的形式传过去,接收的时候把parameterType改为
其中 id 和 name 是对应你表的字段,两个 param 名字随便定义
<association column="{param1=id,param2=name}" property="User" select="getUser"></association>
<select id="getUser" resultMap="UserMap" parameterType="java.util.Map">
SELECT * FROM user_table WHERE id = #{param1} and name = #{param2}
</select>
到此这篇关于mybatis的association传递参数问题的文章就介绍到这了,更多相关mybatis的association传递参数内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: mybatis的association传递参数问题示例
本文链接: https://www.lsjlt.com/news/174823.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0