Hibernate primary key generation policy strategy = "increment" error violation uniqueness constraint
Background
In July 2018, the system burst a bug. Is to support the Excel import function, import the second time different from the template of data, report an error, in violation of the uniqueness constraint. It is useless to restart Tomcat before it can be used again. But only to one file.
Analysis.
Tomcat needs to be restarted, which should be due to the cache.
Reason
After analyzing all the code, the temporary data is changed from clear to new. No.
Memory usage monitoring, after importing the template, it will return to normal, not
Finally, looking at the exception to find the cause, it is found that the primary key strategy of Hibernate is strategy = "increment".
Try
Could it be that the hibernate primary key policy is selected incorrectly, because the selected primary key policy simply cannot be deleted.
Collect
All primary key policies of Hibernate
Https://www.cnblogs.com/hoobey/p/5508992.html
Solve
Select the program to automatically generate the primary key strategy, and strategy = "assigned" after adjustment