Package org.hibernate.id
Class Assigned
- java.lang.Object
-
- org.hibernate.id.Assigned
-
- All Implemented Interfaces:
Serializable
,ExportableProducer
,BeforeExecutionGenerator
,Generator
,Configurable
,StandardGenerator
,IdentifierGenerator
public class Assigned extends Object implements IdentifierGenerator, StandardGenerator
AnIdentifierGenerator
that returns the current identifier assigned to an instance.- See Also:
- Serialized Form
- Implementation Note:
- This also implements the
assigned
generation type inhbm.xml
mappings.
-
-
Field Summary
-
Fields inherited from interface org.hibernate.id.IdentifierGenerator
CONTRIBUTOR_NAME, ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
-
-
Constructor Summary
Constructors Constructor Description Assigned()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowAssignedIdentifiers()
Determine if this generator allows identifier values to be manually assigned to the entity instance before persisting it.void
configure(Type type, Properties parameters, ServiceRegistry serviceRegistry)
Configure this instance, given the value of parameters specified by the user as<param>
elements.Object
generate(SharedSessionContractImplementor session, Object obj)
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.generator.BeforeExecutionGenerator
generatedOnExecution
-
Methods inherited from interface org.hibernate.id.Configurable
create, initialize
-
Methods inherited from interface org.hibernate.generator.Generator
generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
-
Methods inherited from interface org.hibernate.id.IdentifierGenerator
generate, getEventTypes, registerExportables, supportsJdbcBatchInserts
-
-
-
-
Method Detail
-
generate
public Object generate(SharedSessionContractImplementor session, Object obj) throws HibernateException
Description copied from interface:IdentifierGenerator
Generate a new identifier.- Specified by:
generate
in interfaceIdentifierGenerator
- Parameters:
session
- The session from which the request originatesobj
- the entity or collection (idbag) for which the id is being generated- Returns:
- a new identifier
- Throws:
HibernateException
- Indicates trouble generating the identifier
-
configure
public void configure(Type type, Properties parameters, 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 descriptorparameters
- param values, keyed by parameter nameserviceRegistry
- Access to service that may be needed.- Throws:
MappingException
- If configuration fails.
-
allowAssignedIdentifiers
public boolean allowAssignedIdentifiers()
Description copied from interface:Generator
Determine if this generator allows identifier values to be manually assigned to the entity instance before persisting it. This is useful when, for example, needing existing assigned values to be used as identifiers and falling back to generated values by default.- Specified by:
allowAssignedIdentifiers
in interfaceGenerator
- Returns:
true
if this generator allows pre-assigned identifier values,false
otherwise (default).
-
-