首页 > 代码库 > 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"
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。