MyBatis 是不是不支持 批量插入 id自增长的数据
1个回答
展开全部
我这样写的。
<insert id="addTMsgSmsinfoForBatch" parameterType="java.util.List">
<selectKey resultType="long" keyProperty="id" order="BEFORE">
SELECT T旦供测佳爻簧诧伪超镰_MSG_SMSINFO_SEQ.NEXTVAL AS id FROM dual
</selectKey>
INSERT INTO T_MSG_SMSINFO ( <include refid="columns_auotmsgsending" /> ) VALUES
<foreach collection="list" item="item" index="index"
separator=",">
( #{item.id},#{item.ecid},#{item.userid},#{item.sendermsisdn},#{item.receiverinfo},
#{item.totalrec},#{item.smsorigin},#{item.originid},#{item.smscontent},#{item.smstype},
#{item.scheduletime},#{item.auditstatus},#{item.inserttime},#{item.updatetime}
)
</foreach>
</insert>
就是在:
<selectKey resultType="long" keyProperty="id" order="BEFORE">
SELECT T_MSG_SMSINFO_SEQ.NEXTVAL AS id FROM dual
</selectKey>
有问题
<insert id="addTMsgSmsinfoForBatch" parameterType="java.util.List">
<selectKey resultType="long" keyProperty="id" order="BEFORE">
SELECT T旦供测佳爻簧诧伪超镰_MSG_SMSINFO_SEQ.NEXTVAL AS id FROM dual
</selectKey>
INSERT INTO T_MSG_SMSINFO ( <include refid="columns_auotmsgsending" /> ) VALUES
<foreach collection="list" item="item" index="index"
separator=",">
( #{item.id},#{item.ecid},#{item.userid},#{item.sendermsisdn},#{item.receiverinfo},
#{item.totalrec},#{item.smsorigin},#{item.originid},#{item.smscontent},#{item.smstype},
#{item.scheduletime},#{item.auditstatus},#{item.inserttime},#{item.updatetime}
)
</foreach>
</insert>
就是在:
<selectKey resultType="long" keyProperty="id" order="BEFORE">
SELECT T_MSG_SMSINFO_SEQ.NEXTVAL AS id FROM dual
</selectKey>
有问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询