<insert id="saveBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id" > INSERT INTO SMS_TEMPLATE( USER_ID, SIGNATURE, TYPE, SMS_TEMPLATE, POST_FIX, ACTIVITY_ID, IS_ACTIVITY, ACTIVITY_PLATFORM ) VALUES <foreach collection="list" item="item" index="index" separator=","> ( #{item.userId} ,#{item.signature} ,#{item.type} ,#{item.smsTemplate} ,#{item.postFix} ,#{item.activityId} ,#{item.isActivity} ,#{item.activityPlatform}) </foreach> </insert>
Mybatis batch insert to get self-incrementing primary key
Note: Mybatis supports the function of returning the primary key for batch insertion since 3.3.1, please check whether the mybatis version supports it first .
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326271501&siteId=291194637
Ranking