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
}