Solve the problem that the primary key of mybatisplus inserted data is suddenly large
1. Enter the corresponding database in the administrator window, and then enter the following instructions:
alter table sys_user AUTO_INCREMENT=30;
sys_user is the name of the data table to be modified, and 30 is to modify the self increment starting value to 30
In this way, the primary key value of the data table will return to normal
2. In the entity class of the project, add a @Tableid annotation to the primary key of the class
package baocms.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "sys_user")
public class User {
@TableId(value = "id",type = IdType.AUTO)
private Integer id;
private String username;
private String password;
private String nickname;
private String email;
private String phone;
private String address;
}
Read More:
- Using mybatis statement.getGenreatedKeys(); usegeneratedkeys = “true”; using self incrementing primary key to get primary key value policy and Oracle do not support self incrementing, Oracle uses sequence
- How to Solve “413 request entity too large” Error
- [Solved] Specified key was too long; max key length is 767 bytes
- Mybatis sets the primary key Auto-Increment error: No setter found for the keyProperty
- How to Solve SSM JSON Chinese Messy Code Issue
- How to Solve Swagger Always Displays “basic-error-controller” Issue
- How to Solve IDEA Error: Command line is too long
- How to Solve JasperFillManager.fillReport Stuck issue (No Error and No Processing)
- Rancher application service error: request entity too large
- [Solved] mybatisplus BaseMapper Error: required a single bean, but 2 were found
- When the database table field is set to self incrementing, use the entity class to insert or update the data to solve the error (Hibernate Framework)
- The @value annotation of springboot adds the default value to solve the startup error caused by the non-existent key
- How to Solve Error: Your ApplicationContext is unlikely to start due to a @ComponentScan of the default package.
- How to Solve ERROR: Java 1.7 or later is required to run Apache Drill
- JAVA: How to Read JSON Format Data (Web Game Development)
- How to Solve idea com.baomidou Error
- How to Solve JUnit Debugging initializationerror ERROR
- Public Key Retrieval is not allowed [How to Solve]
- How to Solve Flick operate Error: not serialized
- How to Solve JAR pack error: Error resolving template [/userInfo], template might not exist or might not be accessib