Hibernate face Test---Hibernate primary key generation strategy (the primary key generation strategy for Oracle data use) __oracle

Source: Internet
Author: User
Tags db2 generator uuid

Hibernate the primary key generation policy

<class name= "Customers" table= "Customers" >

<id name= "id" column= "id" >

<!--primary key generation strategy-->

<generator class= "native" ></generator>

</id>

<class>

<id> tag is a unique identifier for each instance, a unique identifier to have a primary key generator, and an optional <generator> child element is the name of a Java class used to generate a unique identity for an instance of the persisted class.

All primary key generators implement the Org.hibernate.id.TableLoGenerator interface

The following is a discussion of the shortcut name of the Hibernate built-in generator and the use of

Divided into the following categories:

Increment,identity,sequence,

Hilo, Seqhilo, uuid, GUID, native, assigned, select, Foreign, sequence-identity

To introduce the role and significance of these values:

Increment

Used to generate a unique identifier for a long and short or int type, which can only be used if no other processes are inserting data into the same table, and do not use the

IEntity

Provides support for the built-in identity fields for Db2,mysql,ms SQL server,sybase and Hypersonicsql, and the returned identifier is long,short or int type.

Sequence

Use the sequence in the Db2.,postgresql,sap Db,mckoi, and use the builder in the InterBase. The identifier returned is long,short or int type.

Hilo

Using a high/low algorithm to efficiently long,short, get an int type identifier, giving the definition of two tables and fields as a high position source. The identifier generated by the high-low-level algorithm is unique only in a particular database.

Seqhilo

Use a high/low algorithm to efficiently generate Long,short to get an int type identifier, given the name of a database sequence

Uuid

Generates a string-type identifier with a 128-bit UUID algorithm, which is unique across a network, and the UUID is encoded as a string of 32-bit 16-digit digits

Guid

Using database-generated GUID strings in MS SQL Server and MySQL

Native

Select Identity,sequence to obtain a Hilo in the database based on the capabilities of the underlying databases

Assigned

Let the application assign an identifier to the object before Save (), which is the default build policy when the <geneerator> element is not specified

Select

Select a row of unique primary keys through a database trigger and return a primary key value to assign a primary key

Foreign

The identifier of another associated object, usually combined with the <ont-to-one>
Sequence-identity

A special sequence generation strategy that enables the database sequence to generate the actual value, but combines it with the JDBC3 Getgeneratedkeys to return the generated value when the INSERT statement executes, and so far only the object-oriented JDK1.4 Oracle The 10g driver supports this strategy, noting that the comments for the INSERT statements were closed because of a bug in the Oracle driver.

To summarize, the use of Oracle data is:

1) assigned
2) Hilo
3) Seqhilo
4) Increment
5) identity
6) Sequence
7) Native Way.
8) Uuid.hex 9) uuid.string
Foreign)

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.