Database primary key conflict resolution

Source: Internet
Author: User

In the new project, testers respond to a simple save function, sometimes useful, sometimes unsuccessful, and need to retry many times.

I looked at the original code logic, did not find any problems, conducted a local test, did not find the case of unsuccessful.

By looking through the official environment log, found some ID duplicate error, the original is this engaged.

The ID comment for the original entity class is written like this:

@GenericGenerator (name= "generator", strategy= "increment")    @Id    @GeneratedValue (generator= "generator") @ Column (name = "id", unique = true, Nullable = false) public Long GetId () {return this.id;}


There is no problem with the local single tomcat, and the problem is in the cluster that can be put into the production environment.


A detailed explanation can beseen: http://articles.e-works.net.cn/pc_server/article101508.htm

@Id    @GeneratedValue (strategy=generationtype.identity)    @Column (name = "Id", unique = true, Nullable = False) Public    Long getId () {        return this.id;    }


Database primary key conflict resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.