reset password
Author Message
sxiao11
Posts: 13
Posted 17:54 Feb 04, 2016 |

I have 3 existing users in my database and when i submit a new user registration form, the error shows:" ERROR: duplicate key value violates unique constraint "users_pkey",Detail: Key (id)=(1) already exists". when i tried one more time, it shows  "ERROR: duplicate key value violates unique constraint "users_pkey",Detail: Key (id)=(2) already exists", and after the third time try with error "ERROR: duplicate key value violates unique constraint "users_pkey",Detail: Key (id)=(3) already exists", i can successfully add new user to my database. I think the error happened because when the application tried to add a new user, the id of the new user did not automatically increment after the existing user id. And it only happens when i recreate all the tables.  Can you please help me to figure out why? thank you very much. 

cysun
Posts: 2935
Posted 10:10 Feb 05, 2016 |

Change the hibernate_sequence so it starts from a large number (e.g. 100 or 1000) instead of 0. See springmvc-create.sql for example.

Last edited by cysun at 10:10 Feb 05, 2016.
sxiao11
Posts: 13
Posted 11:28 Feb 05, 2016 |
cysun wrote:

Change the hibernate_sequence so it starts from a large number (e.g. 100 or 1000) instead of 0. See springmvc-create.sql for example.

Thank you very much, it's solved.