Mybatis 返回主键

<insert id="insert" parameterType="com.patest.entiy.UserInfo"
        useGeneratedKeys="true" keyProperty="userId">
        insert into user_info (user_id,
        usrpf_id, username,
        password, classroom, is_teacher,
        is_admin,
        is_active, last_login,
        add_time)
        values (#{userId,jdbcType=INTEGER},
        #{usrpfId,jdbcType=INTEGER},
        #{username,jdbcType=VARCHAR},
        #{password,jdbcType=VARCHAR}, #{classroom,jdbcType=VARCHAR},
        #{isTeacher,jdbcType=INTEGER},
        #{isAdmin,jdbcType=INTEGER},
        #{isActive,jdbcType=INTEGER},
        #{lastLogin,jdbcType=TIMESTAMP},
        #{addTime,jdbcType=TIMESTAMP})
</insert>
@Test
    public void test_insertUserInfo() throws Exception {
//      List<UserInfo> data=new ArrayList<UserInfo>();
//      data.add(new UserInfo(1, "hsah", "sajdhk", "das", 1, 1, 1,
//              Calendar.getInstance().getTime(), Calendar.getInstance().getTime()));
        System.out.println(testObj.insert(new UserInfo(1, "hds1231assah", "sajdhk", "das", 1, 1, 1,
                Calendar.getInstance().getTime(), Calendar.getInstance().getTime())));
    }

你可能感兴趣的:(Mybatis 返回主键)