http://blog.csdn.net/dr_lf/article/details/41380303
在使用mybatis进行批量插入时,发现对于使用oracle的自动增长序列时提示 :
ORA-02287: 此处不允许序号 的错误,下面的这种使用可以解决问题:
<!-- 批量插入 -->
<insert id="inserts" parameterType="java.util.List">
insert into PRESON
select SEQ_PRESON_ID.NEXTVAL,A.* from(
<foreach collection="list" item="item" index="index"
separator="UNION">
SELECT
#{item.presonName},
#{item.presonTel},
#{item.presonEmail},
#{item.presonAge}
from dual
</foreach>
) A
</insert>
<result property="FLD_NUMBER" column="FLD_NUMBER" javaType="double" jdbcType="NUMERIC"/>
mybatis 配置数据源,mapper, 当只有一个package 的时候,不能使用.*,它会找不到。
直接使用pakcage 名字既可以。
<update id="batchUpdate" parameterType="java.util.List">
<foreach collection="list" item="item" index="index" open="begin" close=";end" separator=";">
update test
<set>
test=${item.test}+1
</set>
where id = ${item.id}
</foreach>
</update>
mybatis 批量插入此处不允许序列
猜你喜欢
转载自a545807638.iteye.com/blog/2270360
今日推荐
周排行