批量新增
Java:
List<OrderPri> orderPris = new ArrayList<OrderPri>();
orderPris.add(new OrderPri(null,"004", 1, null));
orderPris.add(new OrderPri(null,"005", 2, null));
System.out.println(JSON.toJSONString(orderPriMapper.insertBatch(orderPris)))
xml
<insert id = "insertBatch">
insert into order_pri(order_num, is_del)values
<foreach collection="list" item="it" separator=",">
(#{it.orderNum, jdbcType = VARCHAR}, #{it.isDel, jdbcType = INTEGER})
</foreach>
批量更新
根據集合更新某一個字段
Java:
List<OrderPri> orderPris = new ArrayList<OrderPri>();
orderPris.add(new OrderPri(1,"004", 1, null));
orderPris.add(new OrderPri(2,"005", 2, null)); System.out.println(JSON.toJSONString(orderPriMapper.updateByIds(orderPris)));
xml:
<update id="updateByIds">
update order_pri set is_del = 1
where id in
<foreach collection="list" separator="," item="it" open="(" close=")">
#{it.id, jdbcType = INTEGER}
</foreach>
</update>
比較日期的年月
and DATE_FORMAT(start_date, '%Y-%m') = DATE_FORMAT(#{startDate}, '%Y-%m')