How does mybatis get the self-increasing id after successful insertion

controller

 

service:

xml

<insert id="insertUser" keyProperty="id" useGeneratedKeys="true"
        parameterType="SysUser">
        insert into
        sys_user(name,user_name,phone,pwd,status,create_time,is_del,company_id,last_login_time,salt)values(#{name},#{userName},#{phone},#{pwd},#{status},CURRENT_TIMESTAMP,0,#{companyId},#{lastLoginTime},#{salt})
    </insert>

 

You can get the self-increasing id through sysUser.getId in the service

Guess you like

Origin blog.csdn.net/qq_37557563/article/details/90442108