获取插入的数据的id

<insert id="insert" parameterType="com.zknw.sysmanage.model.SysUser" useGeneratedKeys="true" keyProperty="userId">
<!--   keyProperty:DO类中的id属性   keyColumn:数据库的id类  -->
<!--   resultType:声明数据类型 order:声明执行时间  after/before-->
    <selectKey keyProperty="userId" keyColumn="userid" resultType="Integer" order="AFTER">
        select last_insert_id();
    </selectKey>
    insert into sys_user
    <trim prefix="(" suffix=")" suffixOverrides=",">
        <if test="userName != null">
            username,
        </if>
        <if test="passWord != null">
            password,
        </if>
        <if test="unEnabled != null">
            unenabled,
        </if>
        <if test="dateCreated != null">
            datecreated,
        </if>
        <if test="dateLastPasswordChange != null and dateLastPasswordChange!=''">
            datelastpasswordchange,
        </if>
        <if test="dateLastLogin != null and dateLastPasswordChange!=''">
            datelastlogin,
        </if>
        <if test="dateLastActivity != null and dateLastPasswordChange!=''">
            datelastactivity,
        </if>
        <if test="organ_id != null and organ_id!=''">
            organ_id,
        </if>
        <if test="organ_name != null and organ_name!=''">
            organ_name,
        </if>
        <if test="team != null and team!=''">
            team,
        </if>
        <if test="job != null and job!=''">
            job,
        </if>
        <if test="jobType != null and jobType!=''">
            jobType,
        </if>
        <if test="dob != null and dob!=''">
            dob ,
        </if>
        <if test="grade != null and grade!=''">
            grade,
        </if>
        <if test="create_user_id != null and create_user_id!=''">
            create_user_id,
        </if>
        <if test="update_date != null and update_date!=''">
            update_date,
        </if>
        <if test="create_user_name != null and create_user_name!=''">
            create_user_name,
        </if>
        <if test="update_user_name != null and update_user_name!=''">
            update_user_name,
        </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
        <if test="userName != null">
            #{userName},
        </if>
        <if test="passWord != null">
            #{passWord},
        </if>
        <if test="unEnabled != null">
            #{unEnabled},
        </if>
        SYSDATE(),
        <if test="dateLastPasswordChange != null and dateLastPasswordChange!='' ">
            dateLastPasswordChange,
        </if>
        <if test="dateLastLogin != null and dateLastLogin!=''">
            dateLastLogin,
        </if>
        <if test="dateLastActivity != null and dateLastActivity!=''">
            dateLastActivity,
        </if>
        <if test="organ_id != null">
            #{organ_id},
        </if>
        <if test="organ_name != null">
            #{organ_name},
        </if>
        <if test="team != null">
            #{team},
        </if>
        <if test="job != null">
            #{job},
        </if>
        <if test="jobType != null">
            #{jobType},
        </if>
        <if test="dob != null">
            #{dob},
        </if>
        <if test="grade != null">
            #{grade},
        </if>
        <if test="create_user_id != null">
            #{create_user_id},
        </if>
        <if test="update_date != null">
            #{update_date},
        </if>
        <if test="create_user_name != null">
            #{create_user_name},
        </if>
        <if test="update_user_name != null">
            #{update_user_name},
        </if>
    </trim>

你可能感兴趣的:(获取插入的数据的id)