传入的参数只要是list类型的参数就行了。。。。。。。。。。。。。。1、批量插入 <insert id="insertBatch" parameterType="java.util.List"> INSERT INTO T_CITY_INDEX( id,city_code ) select SEQ_CITY_INDEX.NEXTVAL,cd.* from( <foreach collection="list" item="item" index="index" close=")" open="(" separator="union"> select #{item.cityCode,jdbcType=VARCHAR}, #{item.cityName,jdbcType=VARCHAR} from dual </foreach> ) cd</insert> 2、批量跟新 <update id="updateBatch" parameterType="java.util.List"> <foreach collection="list" item="item" index="index" open="begin" close=";end;" separator=";"> update T_CITY_INDEX t set t.city_name= #{item.cityName,jdbcType=VARCHAR} , t.district_name= #{item.districtName,jdbcType=VARCHAR} , where t.id = #{item.id,jdbcType=NUMERIC} </foreach></update>
时间: 2024-10-24 22:36:57