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

    1. <?xml version="1.0" encoding="UTF-8" ?>  
    2. <!DOCTYPE mapper  
    3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
    4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">  
    5.   
    6. <mapper namespace="test">  
    7.     <insert id="insertUser" parameterType="dancheng.mybatis.po.User">  
    8.         <!--  
    9.             keyProperty:将查询出的主键设置到parameterType中的哪个属性上  
    10.             order:相对于sql语句的执行顺序  
    11.             resultType:指定返回值类型  
    12.             LAST_INSERT_ID():获取ID函数  
    13.         -->  
    14.         <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">  
    15.             SELECT LAST_INSERT_ID()  
    16.         </selectKey>  
    17.         insert into user(username,birthday,sex,address) value(#{username},#{birthday},#{sex},#{address})  
    18.     </insert>  
    19. </mapper>  
    1. <mapper namespace="test">  
    2.     <insert id="insertUser" parameterType="dancheng.mybatis.po.User">  
    3.         <!--  
    4.             keyProperty:将查询出的主键设置到parameterType中的哪个属性上  
    5.             order:相对于sql语句的执行顺序  
    6.             resultType:指定返回值类型  
    7.             LAST_INSERT_ID():获取ID函数  
    8.         -->  
    9.         <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">  
    10.             SELECT uuid()  
    11.         </selectKey>  
    12.         insert into user(id,username,birthday,sex,address) value(#{id}.#{username},#{birthday},#{sex},#{address})  
    13.     </insert>  
    14. </mapper>  
  • 相关阅读:
    NOIP201208同余方程
    NOIP模拟赛 最佳组合
    NOIP模拟赛 拓展
    CF1253E Antenna Coverage(DP)
    LOJ6033「雅礼集训 2017 Day2」棋盘游戏 (博弈论,二分图,匈牙利算法)
    CF582E Boolean Function(DP,状态压缩,FMT)
    CF750G New Year and Binary Tree Paths(DP)
    Codeforces Round 596 题解
    AGC008E Next or Nextnext(组合计数,神奇思路)
    ARC082E ConvexScore(神奇思路)
  • 原文地址:https://www.cnblogs.com/gtbky/p/8873100.html
Copyright © 2011-2022 走看看