美文网首页
Mybatis 做添加返回添加数据的id

Mybatis 做添加返回添加数据的id

作者: 月哥说了算 | 来源:发表于2019-07-18 11:13 被阅读0次

返回的id存在传过来的实体类中,可以直接从实体类中获取。
resultType:返回数值的类型
order:添加前获取还是添加后获取
keyProperty:返回的字段

<insert id="add" parameterType="com.gzy.health.pojo.CheckGroup">
        INSERT into t_checkgroup (code, name, helpCode, sex, remark, attention) values
        (#{code},#{name},#{helpCode},#{sex},#{remark},#{attention})
        <selectKey resultType="integer" order="AFTER" keyProperty="id">
            select LAST_INSERT_ID()
        </selectKey>
    </insert>

相关文章

网友评论

      本文标题:Mybatis 做添加返回添加数据的id

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