1. Primary KEY (ID)
Hibernate's primary key generation strategy is as follows:
1) assigned
The primary key is generated by an external program and is specified before save ().
2) Hilo
The primary key generation mechanism implemented by the HI/LO algorithm requires additional database tables or fields to provide high-level value sources.
3) Seqhilo
Similar to Hilo, the primary key generation mechanism implemented by the HI/LO algorithm requires a Sequence in the database, which is suitable for databases that support Sequence, such as Oracle.
4) Increment
The primary key is incremented in numerical order. The implementation mechanism of this method is to maintain a variable in the current application instance to hold the current maximum value, and then add 1 to the primary key each time a primary key is generated. The possible problem with this approach is that it cannot be used under a cluster.
5) identity
Adopt the primary key generation mechanism provided by the database. such as DB2, SQL Server, MySQL in the primary key generation mechanism.
6) Sequence
The primary key is generated using the sequence mechanism provided by the database. such as the sequence in Oralce.
7) native
Hibernate uses the identity, Hilo, and sequence as the primary key generation method according to the database used in its own judgment.
8) Uuid.hex
Hibernate generates 16 binary values based on the 128-bit UUID algorithm (encoded with a string of length 32) as the primary key.
9) uuid.string
Similar to Uuid.hex, the generated primary key is not encoded (length 16) and cannot be applied to the PostgreSQL database.
) Foreign
Use the identifier of another associated object as the primary key.
Examples of primary key configurations are:
<id name= "id" column= "id" type= "java.lang.Integer" > <generator class= "native"/> </id>