Hibernate's Generator attribute has 7 classes-meaning and usage

Source: Internet
Author: User
Tags generator mysql database oracle database
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" >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.