标签:
下面是我的Mapper配置
1 <insert id="insertXiangce" parameterType="XiangCe"> <!-- useGeneratedKeys="true" keyProperty="paid" --> 2 3 <selectKey keyProperty="paid" resultType="Integer" order="BEFORE" statementType="STATEMENT"> 4 select seq_photoAlbum_paid.nextval from dual 5 </selectKey> 6 7 insert into photoAlbum (paid,userid,pname,pdescribtion,fpath,ptime,pcount) values(#{paid},#{userid}, 8 #{pname},#{pdescribtion},‘images\\pic-none.png‘,CURRENT_DATE,0) 9 <!-- <selectKey keyProperty="paid" resultType="java.math.BigDecimal" order="AFTER" > 10 select max(paid) from photoAlbum 11 </selectKey> --> 12 </insert> <!-- CURRENT_DATE 当前时间 -->
一开始试了各种方法返回的值都是1(自增数),原来是因为dao层接口返回值应该设为void , 而不是Integer ,设为void就正常了...
Mybatis中使用Oracle插入数据返回新记录主键ID的问题
标签:
原文地址:http://www.cnblogs.com/xiaocunchu/p/4851009.html