美文网首页
sql Insert 返回ID

sql Insert 返回ID

作者: 大树下的木房子 | 来源:发表于2018-03-12 09:41 被阅读0次

ID是自增型

在inset 语句前加入如下语句,返回的实体类中的Id 就是insert 语句的I的Id

<selectKey resultType="java.lang.Integer" keyProperty="Id" order="AFTER">

        SELECT LAST_INSERT_ID()

</selectKey>

ID是非自增型

<selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">

        SELECT uuid()

</selectKey>

keyProperty:将查询出的主键设置到parameterType中的哪个属性上  

order:相对于sql语句的执行顺序  

resultType:指定返回值类型  

LAST_INSERT_ID():获取ID函数  

相关文章

网友评论

      本文标题:sql Insert 返回ID

      本文链接:https://www.haomeiwen.com/subject/cpopfftx.html