如何在xml中传入list参数
Posted 冰凌花花~
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在xml中传入list参数相关的知识,希望对你有一定的参考价值。
mapper.xml文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xxx.xx.cms.dal.extdao.GroupByMaterialMapper"> <select id="groupByMaterialIds" resultType="com.xxx.xx..cms.dal.extdomain.GroupByMaterialDO"> select t1.material_id AS materialId, t2.material_name AS materialName, t2.material_type AS materialType, t1.position_id AS positionId, t5.position_name AS positionName, t1.project_id AS projectId, t3.project_name AS projectName, t1.task_id AS taskId,t4.task_name AS taskName from xspace_task_material_pre t1 left join xspace_material_pre t2 on t1.material_id = t2.id left join xspace_delivery_project_pre t3 on t1.project_id = t3.id left join xspace_delivery_task_pre t4 on t1.task_id = t4.id left join xspace_content_position_pre t5 on t1.position_id = t5.id <where> t1.material_id in <foreach close=")" collection="materialIds" item="listItem" open="(" separator=","> #{listItem} </foreach> </where> order BY t1.material_id </select> </mapper>
mapper.java文件
import com.xxx.xx.cms.dal.extdomain.GroupByMaterialDO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import java.util.List; /** * * @author * @version 2017/12/5 17:38:29 */ @Mapper public interface GroupByMaterialMapper { /** * * * @param materialIds * @return */ List<GroupByMaterialDO> groupByMaterialIds(@Param("materialIds") List<Long> materialIds); }
以上是关于如何在xml中传入list参数的主要内容,如果未能解决你的问题,请参考以下文章
当传入的参数是list集合的时候怎么在mapper.xml中写sql语句