Python 官方文档:入门教程 => 点击学习
目录根据List批量查询List结果mapper接口mapper.xml文件根据多条件List查询mapper文件DAO片段根据List批量查询List结果 mapper接口 p
public List<Drama> selectByIds(@Param("dramaids")List<Long> dramaIds);
<!-- 根据剧典id list查询剧典 -->
<select id="selectByIds" resultMap="DramaImageResultMap">
select * from drama where drama_id in
<foreach collection="dramaIds" item="dramaId" open="(" close=")" separator=",">
#{dramaId}
</foreach>
</select>
数组参数
//接口方法
ArrayList<User> selectByIds(Integer [] ids);
//xml映射文件
<select id="selectByIds" resultMap="BaseResultMap">
select
*
from user where id in
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
#{item}
</foreach>
</select>
List参数
//接口方法
ArrayList<User> selectByIds(List<Integer> ids);
//xml映射文件
<select id="selectByIds" resultMap="BaseResultMap">
Select
<include refid="Base_Column_List" />
from jria where ID in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="selectWhere" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from table
<where>
table.a = a and table.b in
<foreach collection="list" item="item" index="index" open="(" separator="," close=")">
'${item}'
</foreach>
</where>
</select>
List<T> selectWhere(@Param("list")List<String> list ,@Param("a") String a);
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: Mybatis如何根据List批量查询List结果
本文链接: https://www.lsjlt.com/news/142140.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