Since the first use mybatisplus and new learning java to do the project, I do not understand these things.
The easiest serviceImpl of getById have found out something really embarrassing.
Read a few answers online. Statistics about:
1. The data table has changed, but the entity does not make changes https://blog.csdn.net/Tomwildboar/article/details/89530083
2. is the primary key of the wrong type https://blog.csdn.net/BennyShi1998/article/details/85218936
Feel it is quite tricky, the results of the investigation a bit, are not these problems!
Suddenly a eureka moment, this entity primary key seems to really not quite right.
@Data @EqualsAndHashCode(callSuper = true) @Accessors(chain = true) public class Role extends BaseEntity { @TableField(exist = false) private static final long serialVersionUID=1L; private String name; private Integer sort; private String description; }
Which is what serialVersionUID = 1L Ghosts, I obviously id of the database!
This is a serialized version of id, regardless of him. Coupled with their own id
@TableId(type = IdType.AUTO) private Long id;
Compiler has passed, getById it took to the entity, comfortable