当前位置:网站首页>The new MySQL table has a self increasing ID of 20 bits. The reason is

The new MySQL table has a self increasing ID of 20 bits. The reason is

2022-04-23 16:48:00 A coir boat in the broken white clouds

since mybaitis-plus Appearance , We are used to automatically generating code , Although it saves a lot of development time , But it's also easy to ignore some details .
In a business operation , I need to add a table a And table b The data of , surface a Add normal , surface b It opened my eyes
 Insert picture description here
I don't understand , So I went online to find a solution .
Scheme 1 :

TRUNCATE TABLE tablename

Da baa !

Option two :
 Insert picture description here
Da baa !

So I tried to add a piece of data to the database :
 Insert picture description here
This shows that it is not a database problem , That's my code !
By a colleague , Then enter the entity class to view :
 Insert picture description here

No problem , Then go to code logic , Found my watch a The entity class of does not add

type = IdType.Auto

Selfishness is not the problem , Because my watch a The addition of data is very normal , What's not normal is the watch b, But I still treat a dead horse as a living horse doctor , Restart the project with a try mentality , add to , success 了 !
 Insert picture description here
Milk thought ~

ps: If... Is not specified when defining the entity class @TableId(type=IdType.AUTO), that mybatisPlus Will id The type of is set to IdType.NONE, Use the snowflake algorithm to automatically help you set id Well ~

 A thousand Li dike , Collapse in ant nest , I hope everyone will not be defeated by small details 

版权声明
本文为[A coir boat in the broken white clouds]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231400068490.html