Generate Primary Key
There are 4 types to generate a primary key:
AUTO
: Hibernate selects the strategy based on the SQL dialect. Normally it's sequence.IDENTITY
: Hibernate uses the auto-increment database column to generate primary key- Doesn't work well with batch because Hibernate requires a primary key for each managed value. Therefore it has to insert immediately
SEQUENCE
: Use a pre-defined sequence to create the primary key. Recommended method because you can choose to cache the sequence or so on.Table
: Use a database table to simulate a sequence, however it create alock
to create sequence in transaction which make it slow.