zoukankan      html  css  js  c++  java
  • mybatis插入一个对象后获取表中自增的主键Id并且传入到插入的的对象中,方便将对象中其他属性赋值给其他以前表主键Id作为非空字段的表

      原本的sql语句为:

    <insert id="xx"  parameterType="com.hrt.partner.model.ShopInsert">
    
    ***********
    
    </insert>

      需要在其中加入2个属性如下:

    <insert id="xx"   useGeneratedKeys="true"  keyProperty="teamId"> 
    
    ***********
    
    </insert>

      useGeneratedKeys 要求数据库本身具备主键自动增长的功能,比如说,mysql,sqlserver可以使用useGeneratedKeys =true 这功能,

      不支持主键自动增长的数据库是不能使用;keyProperty="tempId"设置自增的主键字段名称

      useGeneratedKeys 要求数据库本身具备主键自动增长的功能,比如说,mysql,sqlserver可以使用useGeneratedKeys =true 这功能,不支持主键自动增长的数据库是不能使用

  • 相关阅读:
    PHP Smarty模板的安装
    百度地图API使用方法详解
    总结的一些微信API接口
    WePayUI 快快尝鲜体验
    Python发送邮件
    Python网络编程
    python 内置函数
    Python操作数据库
    Python操作excel
    python之函数
  • 原文地址:https://www.cnblogs.com/lcngu/p/8529170.html
Copyright © 2011-2022 走看看