Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Hibernate primary key generation policy strategy = "increment" error violation uniqueness constraint

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report