Generator of the ID tag of the hibernate

Source: Internet
Author: User
Tags db2 generator mysql in table definition
Generator of Hibernate ID
1.increment
Self-adding sequence, maintained by Hibernate. The initial value is 1, and only int long and short are supported. It is not suitable for multithreading concurrent update database, suitable for single process Access database. cannot be used in a clustered environment
2. Identity
Related to the underlying database, requires that the database support identify, such as MySQL in the Auto_increment,sql Server is identify. Supported databases have Mysql,sql SERVER,DB2, Sybase and Hypersonicsql. supports only int long and short
3. Sequence
The support sequence of the underlying database is required, and the database supporting the sequence is db2,postgresql,oracle,sapdb. supports only int long and short
4. Hilo
Generating a primary key through the Hilo algorithm requires that there is a table Hibernate_unique_key in the current database, and that there is only one int type field Next_hi, there must be a row of data and cannot be changed. can guarantee the uniqueness of the primary key in the same database, but cannot guarantee the uniqueness of the primary key between multiple databases. Hilo primary key generation is maintained by hibernate, so the Hilo method is independent of the underlying database. However, you should not manually modify the value of the table used by the Hi/lo algorithm, or it will cause a major duplicate exception
5. Seqhilo
The use method is similar to the Hilo approach, generating primary keys through the HI/LO algorithm, but requiring the underlying database to support sequence, such as Oracle,db2
6. UUID
An algorithm is used to generate a 32-bit primary key of type string that guarantees that the primary key generated is unique.
Generate PRIMARY Key Example: 8acca38b1c3625bf011c3625c2920001
7. Guid
A special algorithm. Supports SQL Server,mysql. When using SQL Server, the type of the field in the table definition is specified as uniqueidentifier
(I haven't found a better explanation by now)
8. Native
According to the different underlying database, different primary key generation methods are used. If MySQL uses the Idetify method, Oracle uses the sequence method, if the project uses multiple databases, you can use the native method
9. Assigned
The primary key is maintained by the program itself, and a persistent class must manually assign a primary key before being save ()
Select
Retrieves a primary key assigned by a database trigger by selecting the row by some the unique key and retrieving the primary Key value.
The official document was not understood. Later found the explanation of the Internet and then update
Foreign.
For one-to-one association mappings.
Sequence-identity
Let's do it, when do you know what it means?

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.