1. 实体类中对主键加注解
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
2. mapper.xml中添加设置参数
<insert id="addList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
...
</insert>
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
<insert id="addList" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
...
</insert>
本文标题:Mybatis的insert操作,映射id
本文链接:https://www.haomeiwen.com/subject/fukahltx.html
网友评论