How mybatis returns the primary key id? of the inserted record

I"m going to go back to mybatis and add the useGeneratedKeys= "true" keyProperty= "id" keyColumn= "id" attributes to id, but doesn"t feel much use . Has anyone ever returned to success in this way?
description: mysql used by the database.

the code is as follows:
Mapper.xml

    <resultMap id="BaseResultMap" type="com.freedom.clothing.domain.Goods">
        <id column="id" jdbcType="INTEGER" property="id"/>
        <result column="url" jdbcType="VARCHAR" property="url"/>
        <result column="match_num" jdbcType="INTEGER" property="matchNum"/>
        <result column="is_del" jdbcType="BIT" property="isDel"/>
        <result column="group_id" jdbcType="INTEGER" property="groupId"/>
        <result column="source_id" jdbcType="INTEGER" property="sourceId"/>
        <result column="user_id" jdbcType="INTEGER" property="userId"/>
        <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
        <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
    </resultMap>

    <insert id="insertSelective" parameterType="com.freedom.clothing.domain.Goods" useGeneratedKeys="true"
            keyProperty="id" keyColumn="id">
        insert into goods
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="url != null">
                url,
            </if>
            <if test="matchNum != null">
                match_num,
            </if>
            <if test="isDel != null">
                is_del,
            </if>
            <if test="groupId != null">
                group_id,
            </if>
            <if test="sourceId != null">
                source_id,
            </if>
            <if test="userId != null">
                user_id,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                -sharp{id,jdbcType=INTEGER},
            </if>
            <if test="url != null">
                -sharp{url,jdbcType=VARCHAR},
            </if>
            <if test="matchNum != null">
                -sharp{matchNum,jdbcType=INTEGER},
            </if>
            <if test="isDel != null">
                -sharp{isDel,jdbcType=BIT},
            </if>
            <if test="groupId != null">
                -sharp{groupId,jdbcType=INTEGER},
            </if>
            <if test="sourceId != null">
                -sharp{sourceId,jdbcType=INTEGER},
            </if>
            <if test="userId != null">
                -sharp{userId,jdbcType=INTEGER},
            </if>
            <if test="createTime != null">
                -sharp{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateTime != null">
                -sharp{updateTime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>

entity class

public class Goods {
    private Integer id;

    private String url;

    private Integer matchNum;

    private Boolean isDel;

    private Integer groupId;

    private Integer sourceId;

    private Integer userId;

    private Date createTime;

    private Date updateTime;
    
    //getersetter
}

personal opinion:
1. According to the above configuration, it is possible to automatically generate insert without passing in id,id, but this requires that the database table id is also self-incrementing.
2. According to the above configuration, after the return value of the insert method is id, but the insert method is executed, the id of the original object becomes valuable
the source code will decide whether or not to execute the id assignment method populateKeys (), according to the above configuration. The main assignment code is as follows:

Object value = th.getResult(rs, i + 1);
// 
metaParam.setValue(property, value);

I hope I can help you. Thank you

Delete your id field when

is inserted, and delete keyColumn= "id" in sql "select"

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e481de-44c8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e481de-44c8f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?