Package org.hibernate.id
Class UUIDGenerator
- java.lang.Object
-
- org.hibernate.id.UUIDGenerator
-
- All Implemented Interfaces:
ExportableProducer
,Configurable
,IdentifierGenerator
public class UUIDGenerator extends java.lang.Object implements IdentifierGenerator
AnIdentifierGenerator
which generatesUUID
values using a pluggablegeneration strategy
. The values this generator can return includeUUID
,String
and byte[16] Supports 2 config parameters:UUID_GEN_STRATEGY
- names theUUIDGenerationStrategy
instance to useUUID_GEN_STRATEGY_CLASS
- names theUUIDGenerationStrategy
class to use
UUIDGenerationStrategy
:StandardRandomStrategy
(the default, if none specified)CustomVersionOneStrategy
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
UUID_GEN_STRATEGY
static java.lang.String
UUID_GEN_STRATEGY_CLASS
-
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
-
-
Constructor Summary
Constructors Constructor Description UUIDGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static UUIDGenerator
buildSessionFactoryUniqueIdentifierGenerator()
void
configure(Type type, java.util.Properties params, ServiceRegistry serviceRegistry)
Configure this instance, given the value of parameters specified by the user as <param> elements.java.io.Serializable
generate(SharedSessionContractImplementor session, java.lang.Object object)
Generate a new identifier.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.id.IdentifierGenerator
initialize, registerExportables, supportsJdbcBatchInserts
-
-
-
-
Field Detail
-
UUID_GEN_STRATEGY
public static final java.lang.String UUID_GEN_STRATEGY
- See Also:
- Constant Field Values
-
UUID_GEN_STRATEGY_CLASS
public static final java.lang.String UUID_GEN_STRATEGY_CLASS
- See Also:
- Constant Field Values
-
-
Method Detail
-
buildSessionFactoryUniqueIdentifierGenerator
public static UUIDGenerator buildSessionFactoryUniqueIdentifierGenerator()
-
configure
public void configure(Type type, java.util.Properties params, ServiceRegistry serviceRegistry) throws MappingException
Description copied from interface:IdentifierGenerator
Configure this instance, given the value of parameters specified by the user as <param> elements.This method is called just once, following instantiation, and before
IdentifierGenerator.registerExportables(Database)
.- Specified by:
configure
in interfaceConfigurable
- Specified by:
configure
in interfaceIdentifierGenerator
- Parameters:
type
- The id property type descriptorparams
- param values, keyed by parameter nameserviceRegistry
- Access to service that may be needed.- Throws:
MappingException
- If configuration fails.
-
generate
public java.io.Serializable generate(SharedSessionContractImplementor session, java.lang.Object object) throws HibernateException
Description copied from interface:IdentifierGenerator
Generate a new identifier.- Specified by:
generate
in interfaceIdentifierGenerator
- Parameters:
session
- The session from which the request originatesobject
- the entity or collection (idbag) for which the id is being generated- Returns:
- a new identifier
- Throws:
HibernateException
- Indicates trouble generating the identifier
-
-