Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between native and increment id generator type

What is the basic difference between when we use native and increment types id generator in hibernate.

As i was having a entity, in which the generator was previuosly native, but then changed it to incremental for some time, it was working properly. But just yesterday, when i changed in to native again, the insertion is failing saying Contraint Violation.

I have index set up in the id field, which is auto generated.

Am i missing something here.

Thanks

like image 595
M.J. Avatar asked Jun 28 '11 06:06

M.J.


People also ask

What does generator class Native mean?

Native means Your generator will use identity or sequence columns according to what your current database support.

What is hibernate generator class?

A generator class is used to generate an ID for an object, which is going to be inserted in the database as a primary key. The ID is a unique identifier for the objects of the persistent class. We can use any generator classes in our application as per our requirements.


1 Answers

Native is generated by DB - if DB do it. Increment - generates by hibernate that are unique only when no other process is inserting data into the same table.

like image 72
Lorenzo Manucci Avatar answered Sep 24 '22 15:09

Lorenzo Manucci