The primary key generation strategy refers to the <grnerator class= "native"/>
1, native
For Oracle using the Sequence method, for MySQL and SQL Server using identity (the generation of the main key generating mechanism), native is the primary key generation work to the database to complete, hibernate regardless (very often)
2, assigned
When inserting data, the primary key is added by the user himself, and hibernate (very often)
3, Increment
When inserting the data, Hibernate adds an additional primary key to the primary key, but a hibernate instance maintains a counter, so you cannot use this method when multiple instances are running
4, Sequence
Call the database sequence to generate the primary key, set the sequence name, or hibernate cannot find:
<param name= "sequence" >NAME_SEQ</param> (very common in Oracle)
5. Identity
Using the self-added fields of SQL Server and MySQL, this method cannot be placed in Oracle, and Oracle does not support the sequence field, which is used in MySQL and SQL Server.
6, Hilo
Use the Hilo build policy to create an extra table in the database, with the default table name Hibernate_unique_key, the default field of type Integer, and the name Next_hi (less)
We can also set our own custom table names and field names.
<id name= "id" type= "integer" >
<column name= "id"/>
<generator class= "Hilo" >
<param name= "My_unique_key"/>
<param column= "Next_hi"/>
</generator>
</id>
7, Sehilo
Implemented through the Hilo algorithm, but the primary key history is stored in Sequence and is suitable for databases that support Sequence, such as Oracle (less)
8, Uuid.hex
Hibernate will figure out a 128-bit unique value insertion
9, Uuid.string
Hibernate will figure out a 16-bit value to insert
10, Foreign
Use fields from external tables as primary keys
11, select
use triggers to generate primary keys (primarily for early database primary key generation mechanisms, less)