0

I have a table with data being inserted from two different applications. One is a legacy application using INSERT QUERIES and the other one uses hibernate to insert the value.

But the hibernate insert (generator="identity") fails first time(index constraint), when we try to insert after the manual insert has run.

But when we try for the second time, the insert is working. Why this is happening?

Is that hibernate caching the next primary key value and then using that value which is conflicting with manual max+1 insert?

Kindly help

Affil
  • 1

1 Answers1

0

I'm suspecting key generator problem. Ie: your manual inserts uses one mechanism to get the next primary key (selecting max id + 1 maybe) while hibernate use native database method, hence when it try to 'guess' the next primary key it fails

As long as both system use the same method to generate primary key it shouldn't be a problem

gerrytan
  • 40,313
  • 9
  • 84
  • 99