首页 > 代码库 > mybatis 之 parameterType="java.util.List"

mybatis 之 parameterType="java.util.List"

<!-- 添加 -->    <insert id="saveBatchMemberRoleConnRepModel" parameterType="java.util.List">         INSERT INTO member_role_conn         (member_id,role_id,rank_id,time_rang,begin_time,end_time,long_date,get_time,is_delete,add_user,add_time,edit_user,edit_time)          VALUES           <foreach collection="list" item="item" index="index" separator="," >           (#{item.memberId},#{item.roleId},#{item.rankId},#{item.timeRang},#{item.beginTime},#{item.endTime},#{item.longDate},#{item.getTime},#{item.isDelete},#{item.addUser},#{item.addTime},#{item.editUser},#{item.editTime})           </foreach>    </insert>
/**     *      * 批量新增     *      **/    public ServiceMessage<String> saveBatchMemberRoleConnRepModel(            List<MemberRoleConnRepModel> list) {        try {            memberRoleConnRepMapper.saveBatchMemberRoleConnRepModel(list);            return super.returnCorrectResult("批量新增成功!");        } catch (Exception e) {            logger.error(e.getMessage(), e);            return super.returnException("批量新增异常!");        }    }
    /**     *      * 批量新增     *      **/     @Test     public  void testSaveBatch(){            MemberRoleConnRepModelService hessianServer = J1SOAHessianHelper.getService(url,MemberRoleConnRepModelService.class);            List<MemberRoleConnRepModel> list = new ArrayList<MemberRoleConnRepModel>();            MemberRoleConnRepModel obj = createObj()  ;            list.add(obj);            ServiceMessage<String> result = hessianServer.saveBatchMemberRoleConnRepModel(list);            System.out.println(JSONObject.fromObject(result));     }
private MemberRoleConnRepModel createObj() {            MemberRoleConnRepModel obj = new MemberRoleConnRepModel();              /**id**/              obj.setId();              /**会员ID**/              obj.setMemberId();              /**角色ID**/              obj.setRoleId();              /**有效时间限制(all/rang)                             obj.setTimeRang();              /**有效开始时间**/              obj.setBeginTime();              /**有效结束时间**/              obj.setEndTime();              /**持续时长(天)**/             obj.setLongDate();              /**获得时间**/              obj.setGetTime();              /**是否删除(Y/N)**/              obj.setIsDelete();              /**添加人**/              obj.setAddUser();              /**添加时间**/              obj.setAddTime();              /**修改人**/              obj.setEditUser();              /**修改时间**/              obj.setEditTime();            return obj;     }

 

 

 

 

<select id="getTopGoodsEval" parameterType="java.util.ArrayList"            resultType="GoodsComment">        select t.eid,ge.content,ge.goodsid as goodsId from        (        select max(ge.eid)        as eid from goods_evaluation ge where ge.goodsid        in        <foreach collection="values[]" index="index" item="item" open="("                 separator="," close=")">            #{item}        </foreach>        and ge.isdisplay=0 group by ge.goodsid        ) t,goods_evaluation ge where        ge.eid=t.eid    </select>
public GoodsComment getTopGoodsEval(List list);

 

mybatis 之 parameterType="java.util.List"