mybatis怎样批量插入数据到oracle,就算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>
有问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询