zoukankan      html  css  js  c++  java
  • mybatis insert oracle 返回主键

    mybtis返回oracle主键

    只需要加一点代码(红色处的代码)就可以了

    	<!-- 添加记录到临时表 -->
    	<insert id="insertPlaneStatementList" parameterType="planeStatementList">
    		<selectKey keyProperty="id" resultType="java.lang.Integer" order="BEFORE">
    			select prm_plane_statement_list_seq.nextval id from dual
    		</selectKey>
    		insert into prm_plane_statement_list(id,is_delete,zzcbly,fysfxd,project_no,bill_no,bill_type,piaohao,cblx,price,tax,dlf,ssf,psl,ckxm,card,cprq,gplx,jplx,jphsdh,cbhj) VALUES
    		(
    			#{id},
    			#{isDelete},
    			#{zzcbly},
    			#{fysfxd},
    			#{projectNo},
    			#{billNo},
    

      mybatis会自动,通过红色处的代码,获取到主键,然后把主键放入我们要插入的对象中。

    然后在sql语句中,正常写法,通过#{id}获取id就可以了。

    至于映射的方法的返回值,默认还是返回的受影响的行数,但是在mybatis执行完后,对象中就已经存在主键值了。

  • 相关阅读:
    增加新分类daily——“每天学了啥?”
    gcc选项中的编译过程
    一个带路径复制的perl脚本
    git
    mysql explain 详解
    CentOS Python2.4升级到Python2.7
    mongoDb查询
    linux php 扩展
    php-redis 扩展安装
    redis Linux的安装方法
  • 原文地址:https://www.cnblogs.com/yanqin/p/6194594.html
Copyright © 2011-2022 走看看