您的位置:首页 > 其它

mybatis的foreach的使用

2015-06-27 18:39 363 查看
private MarketCategoryConversionRateMapper marketCategoryConversionRateMapper;

List<Integer> ids = new ArrayList<Integer>();
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("allPeopleNum", allmemberNum);
paramMap.put("allConsumeNum", allsalesNum);
paramMap.put("idlist", ids);
this.marketCategoryConversionRateMapper.updateMarketConversionConversionRate(paramMap);

public interface MarketCategoryConversionRateMapper {

void updateMarketConversionConversionRate(Map<String, Object> paramMap);

}

<update id="updateMarketConversionConversionRate" parameterType="map"  >
UPDATE  test SET ALL_PEOPLE_NUM=#{allPeopleNum},ALL_CONSUME_SUM=#{allConsumeNum}
where ID IN
<foreach item="item" index="index" collection="idlist"   open="(" separator="," close=")">
#{item}
</foreach>
</update>

public void insertBatchSpecialCustomer(List<SpecialCustomerEntity> list ) ;

<insert id="insertBatchSpecialCustomer"  parameterType="java.util.List" >
replace into SPECIAL_CUSTOMER
(
ID,
SPECIAL_CUSTOMER_NAME,
CUSTOMER_TYPE ,
member_type,
RULE ,
HOBBY_RULE ,
STATUS,
SALES_REPORT_STATUS ,
CREATE_TIME ,
TRACK_REPORT_STATUS ,
WIFI_REPORT_STATUS
)
VALUES
<foreach collection="list" item="item" index="index" separator="," >
(
#{item.id},
#{item.specialCustomerName},
#{item.customerType},
#{item.memberType},
#{item.rule},
#{item.hobbyRule},
#{item.status},
#{item.salesReportStatus},
#{item.createTime},
#{item.trackReportStatus},
#{item.wifiReportStatus}
)
</foreach>
</insert>

public List<SpecialCustomerEntity> findSpecialCustomerInfoList(List<String> customerTypeList ) ;

<select id="findSpecialCustomerInfoList" parameterType="java.util.List" resultType="SpecialCustomerEntity">
select  ID,SPECIAL_CUSTOMER_NAME as "specialCustomerName",CUSTOMER_TYPE as "customerType",
member_type as "memberType",RULE , HOBBY_RULE as "hobbyRule",status ,
SALES_REPORT_STATUS as "salesReportStatus" ,CREATE_TIME as  "createTime",
TRACK_REPORT_STATUS as "trackReportStatus" ,
WIFI_REPORT_STATUS as "wifiReportStatus"
from SPECIAL_CUSTOMER  where CUSTOMER_TYPE in
(
<foreach collection="list" item="item" index="index" separator="," >
${item}
</foreach>
)
</select>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: