All generators implement the org.hibernate.id.IdentifierGenerator interface. This is a very simple interface. Some applications may choose their own custom implementations, but Hibernate provides a number of built-in implementations. The shortcut names for the built-in generators are as follows:
increment
generates identifiers of type long, short or int, which are unique only when another process does not insert data into the same table. Do not use in a cluster.
identity
supports identity columns in DB2, MySQL, MS SQL Server, Sybase, and HypersonicSQL. The returned identifier is of type long, short, or int.
sequence
uses a sequence in DB2, PostgreSQL, Oracle, SAP DB, McKoi, or a generator in Interbase. The returned identifier is of type long, short, or int
Hilo
uses the hi / lo algorithm to efficiently generate identifiers of type long, short or int, given the table and column (by default, hibernate_unique_key and next_hi, respectively) as a source of hi values. The hi / lo algorithm generates identifiers that are unique to a specific database only.
seqhilo
uses the hi / lo algorithm to efficiently generate identifiers of type long, short or int with a given named database sequence.
Uuid
uses a 128-bit UUID algorithm to generate type string identifiers that are unique on the network (using an IP address). The UUID is encoded as a string of 32 hexadecimal digits in length.
reference
uses the GUID string generated by the database on MS SQL Server and MySQL.
native
selects an identifier, sequence, or hilo depending on the capabilities of the underlying database.
assigned
Allows an application to assign an identifier to an object before calling save (). This is the default strategy if no items are specified.
select
retrieves the primary key assigned by the database trigger by selecting a row using some unique key and obtaining the primary key value.
foreign
uses the identifier of another related object. It is commonly used in conjunction with a primary key association.
sequence identity
A specialized sequence generation strategy that uses the database sequence to generate the actual value, but combines it with JDBC3 getGeneratedKeys to return the generated identifier value as part of the insert statement. This strategy is only supported for Oracle 10g drivers targeting JDK 1.4. Comments on these insert statements are disabled due to an error in the Oracle drivers.
If you are creating a simple application with a small number of concurrent users, you can switch to increment, identifier, hilo , etc. They are easy to configure and do not need much encoding inside db.
Update: Recently we had a problem with idendity, where the primitive type (int) was fixed using the warapper (Integer) type.