Skip to content

使用自增主键时如果字段名不为“id”该如何处理? #124

@ShangFengzhang

Description

@ShangFengzhang
    // mapper接口中的实现
   @Lang(Caching.class)
   @Options(
       useGeneratedKeys = true,
       keyProperty = "id"
   )
   @InsertProvider(
       type = EntityProvider.class,
       method = "insert"
   )
   <S extends T> int insert(S entity);
// pojo类
@Entity.Table(value = "sys_user", remark = "用户表", autoResultMap = true)
public class SysUser {
    @Entity.Column(value = "user_id", id = true, useGeneratedKeys = true)
    private Long userId;
  // ...
}

我必须单独提供一个id字段并实现get/set方法以获取自增主键?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions