0

I am having a constraint violation issue with Hibernate and the constraint is related primary key. I debugged a bit and see that the before insertion, sequence value selection as below

select table_seq.nextval from dual;

runs only at the beginning for the related table. Following the first sequence fetching, the rest utilized by hibernate manually. I mean if the selected sequence is 25 on the first insertion. Rest of the sequences generated automatically by hibernate itself. No more sequence selection triggered. This causes some weird issues like, app runs on two different servers crashes due to primary key constraint.

I found below, but not sure if I am hitting to the same wall. Issue with Hibernate @SequenceGenerator in Spring 3 application

p.s : I am trying to upgrade the app from hibernate 3.x to 5.2.12.

1 Answer 1

0

The problem was with the sequence auto increment value. The entity was set to 50 while db value was 1. I changed the sequence generation logic to old strategy which is ;

hibernate.id.new_generator_mappings -> false
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.