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>  
  • 相关阅读:
    插入排序java代码
    选择排序java代码
    break语句的作用
    while和do-while的区别
    if-else-if-else与switch的区别
    Java中基本类型的转换规则
    如何让计算机最高效的算出2乘以8?
    |和||的作用和区别
    &和&&的作用和区别
    i++和++i的作用和区别
  • 原文地址:https://www.cnblogs.com/gtbky/p/8873100.html
Copyright © 2011-2022 走看看