This article describes the meaning of Hibernate's generator attribute. The generator attribute has 7 classes, and this article briefly describes the meaning and usage of these 7 classes.
[XHTML]View plain copy <class name= "Onlyfun.caterpillar.User" table= "User" > <id name= "id" type= "string" Unsaved-val Ue= "null" > <column name= "user_id"/> <generator class= "Uuid.hex"/> </id> </class>
Hibernate's Generator attribute has 7 classes, this article briefly describes the meaning and usage of these 7 classes.
1, Identity: for MySQL database. Features: Increment
[XHTML] view plain copy <id name= "id" column= "id" > < generator class= "identity"/> </id>
Note: The primary key is specified as the Auto_increment property for the MySQL database when you need to build the table when using an incremental sequence.
2. Sequence: for Oracle database
[XHTML] view plain copy <id name= "id" column= "id" > <generator class= "sequence" > <param name= " Sequence "> sequence name </param> </generator> </id>
3, native: cross-database use, generated by the underlying dialect.
Default.sequence to Hibernate_sequence
[XHTML] view plain copy <id name= "id" column= "id" > <generator class= "native"/> </id>
Note: Hibernate will find the hibernate_sequence sequence in Oracle by default when using native.
If the sequence is not in Oracle, an error is encountered when the Oracle database is connected.
4, Hilo: Through the high-low-level synthesis ID, first build table Hi_value, and then build the column Next_value. Must have an initial value.
[XHTML] view plain copy <id name= "id" column= "id" >