1. UUID is a 32-Bit String, so the size of the database primary key field must be greater than or equal to 32 characters. In addition, if a trigger and sequence are set in the database table, even if the uuid primary key generation policy is used, the uuid will become invalid when hibernate inserts data, instead, the value in sequence is used as the primary key ID. It is equivalent to using UUID as the primary key ID, but it is overwritten by the value in sequence before insertion. Note This. The trigger that deletes the table can be restored.
2. Native means that the implementation of the Primary Key Generation Mechanism will be decided by hibernate. Hibernate uses a specific primary key generation method for different databases based on the definition of the underlying database adapter dialect. (Auto-incrementing fields are used for sqlserver and MySQL, and auto sequence is used for Oracle to generate primary keys)
Note: In this case, Hibernate uses the sequence hibernate_sequence by default. If it is not set in Oracle, the console will generate"Hibernate: Select hibernate_sequence.nextval from dual
Caused by: Java. SQL. sqlexception: ORA-02289: sequence (number) does not exist. Add a sequence named hibernate_sequence to Oracle.
You can also use the following method to specify which sequence to use:
<Generator class = "native">
<Param name = "sequence"> huser_seq </param></Generator>
3. Sequence means that the sequence mechanism provided by the database will be used to generate the primary key. In the HBM. xml ing file, if this primary key ing mechanism is used, you must specify the sequence used to generate the primary key. For example:
<ID name = "userid" type = "Java. Lang. Long">
<Column name = "user_id" precision = "22" scale = "0"/>
<Generator class = "sequence">
<Param name = "sequence"> seq_user </param>
</Generator>
</ID>
ArticleSource: http://muzixiang.iteye.com/blog/858781