Mybatis笔记 -- 批量操作(查询、插入、更新、删除)

批量查询

Mapper接口

/**
 * 根据剧典id list查询剧典
 */
public List<Drama> selectByIds(@Param("dramaIds")List<Long> dramaIds);

mapper.xml

<!-- 根据剧典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>

猜你喜欢

转载自www.cnblogs.com/junzifeng/p/11946941.html