据说一般这样的就行了
<insert id="addControlInfoBatch" parameterType="java.util.List" > insert into T_VEHTRACK_TRACK (TRACK_ID,TRACK_NBR,TRACK_REASON) values <foreach collection="list" item="item" index="index" separator="," > ({item.trackId,jdbcType=VARCHAR}, #{item.trackNbr,jdbcType=VARCHAR}, #{item.trackReason,jdbcType=VARCHAR}) </foreach> </insert>
可是我用的报错,***命令未正确结束,因为我用Oracle,用这个就好了
<insert id="addControlInfoBatch" parameterType="java.util.List" > insert into T_VEHTRACK_TRACK (TRACK_ID,TRACK_NBR,TRACK_REASON) <foreach collection="list" item="item" index="index" separator="union all" > select #{item.trackId,jdbcType=VARCHAR}, #{item.trackNbr,jdbcType=VARCHAR}, #{item.trackReason,jdbcType=VARCHAR} from dual </foreach> </insert>
参考:http://www.iteye.com/problems/85316