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.

Olgun Kaya
  • 2,519
  • 4
  • 32
  • 46

1 Answers1

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
Olgun Kaya
  • 2,519
  • 4
  • 32
  • 46