-
用于为
long
,short
或者int
类型生成 唯一标识。只有在没有其他进程往同一张表中插入数据时才能使用。在集群下不要使用。 -
对 DB2,MySQL,MS SQL Server,Sybase 和 HypersonicSQL 的内置标识字段提供支持。返回的标识符是
long
,short
或者int
类型的。 -
在 DB2,PostgreSQL,Oracle,SAP DB,McKoi 中使用序列(sequence), 而在 Interbase 中使用生成器(generator)。
返回的标识符是
long
,short
或者int
类型的。 -
使用一个高/低位算法高效的生成
long
,short
或者int
类型的标识符。给定一个表和字段(默认分别是hibernate_unique_key
和next_hi
)作为高位值的来源。 -
使用一个高/低位算法来高效的生成
long
,short
或者int
类型的标识符,给定一个数据库序列(sequence)的名字。 -
Generates a 128-bit UUID based on a custom algorithm. The value generated is represented as a string of 32 hexidecimal digits. Users can also configure it to use a separator (config parameter "separator") which separates the hexidecimal digits into 8{sep}8{sep}4{sep}8{sep}4. Note specifically that this is different than the IETF RFC 4122 representation of 8-4-4-4-12. If you need RFC 4122 compliant UUIDs, consider using "uuid2" generator discussed below.
-
Generates a IETF RFC 4122 compliant (variant 2) 128-bit UUID. The exact "version" (the RFC term) generated depends on the pluggable "generation strategy" used (see below). Capable of generating values as
java.util.UUID
,java.lang.String
or as a byte array of length 16 (byte[16]
). The "generation strategy" is defined by the interfaceorg.hibernate.id.UUIDGenerationStrategy
. The generator defines 2 configuration parameters for defining which generation strategy to use:-
Names the UUIDGenerationStrategy class to use
-
Names the UUIDGenerationStrategy instance to use
uuid_gen_strategy_class
uuid_gen_strategy
Out of the box, comes with the following strategies:
-
org.hibernate.id.uuid.StandardRandomStrategy
(the default) - generates "version 3" (aka, "random") UUID values via therandomUUID
method ofjava.util.UUID
-
org.hibernate.id.uuid.CustomVersionOneStrategy
- generates "version 1" UUID values, using IP address since mac address not available. If you need mac address to be used, consider leveraging one of the existing third party UUID generators which sniff out mac address and integrating it via theorg.hibernate.id.UUIDGenerationStrategy
contract. Two such libraries known at time of this writing include http://johannburkard.de/software/uuid/ and http://commons.apache.org/sandbox/id/uuid.html
-
-
在 MS SQL Server 和 MySQL 中使用数据库生成的 GUID 字符串。
-
根据底层数据库的能力选择
identity
、sequence
或者hilo
中的一个。 -
让应用程序在调用
save()
之前为对象分配一个标识符。这是<generator>
元素没有指定时的默认生成策略。 -
通过数据库触发器选择一些唯一主键的行并返回主键值来分配一个主键。
-
使用另外一个相关联的对象的标识符。它通常和
<one-to-one>
联合起来使用。 -
一种特别的序列生成策略,它使用数据库序列来生成实际值,但将它和 JDBC3 的 getGeneratedKeys 结合在一起,使得在插入语句执行的时候就返回生成的值。
目前为止只有面向 JDK 1.4 的 Oracle 10g 驱动支持这一策略。由于 Oracle 驱动程序的一个 bug,这些插入语句的注释被关闭了。
increment
identity
sequence
hilo
seqhilo
uuid
uuid2
guid
native
assigned
select
foreign
sequence-identity