"Go" nhibernate primary key type Introduction

Source: Internet
Author: User
Tags mysql in uuid

Transferred from: http://blog.163.com/wzx_dd/blog/static/1942850722012828934553/

Recently Integrated Framework, using SSH to build a framework, but after the integration, the launch of Tomcat always reported this error, the internet collected and asked colleagues, finally know the reason for the error: The database does not support automatic incrementing the primary key (Oracle does not support) so your key Generation need to be newly set

Through the Internet collection, organized a bit about the primary key self-added knowledge, for later learning to use; 1) the assigned primary key is generated by an external program and does not require hibernate participation. 2) Hilo uses the primary key generation mechanism implemented by the HI/LO algorithm, which requires additional database tables to save the primary key generation history state. 3) Seqhilo similar to Hilo, the primary key generation mechanism implemented by the HI/LO algorithm is simply that the primary key historical state is saved in sequence and is applicable to the database that supports sequence, such as Oracle. 4) The increment 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 if there are multiple instances accessing the same database, the different instances may generate the same primary key as each instance maintains the primary key state, causing the primary key to repeat the exception. Therefore, this approach must be avoided if there are multiple instance accesses to the same database. 5) Identity adopts the primary key generation mechanism provided by the database. such as DB2, SQL Server, MySQL in the primary key generation mechanism. 6) sequence uses the sequence mechanism provided by the database to generate the primary key. such as the sequence in Oralce. 7) native by hibernate according to the underlying database to determine the identity, Hilo, sequence one of the primary key generation mode. 8) Uuid.hex is generated by hibernate based on a 128-bit unique value generation algorithm to generate a 16 binary value (encoded with a string representation of length 32) as the primary key. 9) uuid.string is similar to Uuid.hex, except that the generated primary key is not encoded (length 16). Problems (such as PostgreSQL) may occur in some databases. Foreign use the field of the external table as the primary key
Related Article

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.