Package org.hibernate.id
Class CompositeNestedGeneratedValueGenerator
- java.lang.Object
-
- org.hibernate.id.CompositeNestedGeneratedValueGenerator
-
- All Implemented Interfaces:
Serializable,ExportableProducer,Configurable,IdentifierGenerator,IdentifierGeneratorAggregator
public class CompositeNestedGeneratedValueGenerator extends Object implements IdentifierGenerator, Serializable, IdentifierGeneratorAggregator
For composite identifiers, defines a number of "nested" generations that need to happen to "fill" the identifier property(s). This generator is used implicitly for all composite identifier scenarios if an explicit generator is not in place. So it make sense to discuss the various potential scenarios:-
"embedded" composite identifier - this is possible only in HBM mappings
as
<composite-id/>(notice the lack of both a name and class attribute declarations). The term"embedded"here refers to the Hibernate usage which is actually the exact opposite of the JPA meaning of "embedded". Essentially this means that the entity class itself holds the named composite pk properties. This is very similar to the JPA@IdClassusage, though without a separate pk-class for loading. -
pk-class as entity attribute - this is possible in both annotations (
@EmbeddedId) and HBM mappings (<composite-id name="idAttributeName" class="PkClassName"/>) -
"embedded" composite identifier with a pk-class - this is the JPA
@IdClassuse case and is only possible in annotations
Component.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCompositeNestedGeneratedValueGenerator.GenerationContextLocatorContract for declaring how to locate the context for sub-value injection.static interfaceCompositeNestedGeneratedValueGenerator.GenerationPlanContract for performing the actual sub-value generation, usually injecting it into the determinedcontext
-
Field Summary
-
Fields inherited from interface org.hibernate.id.IdentifierGenerator
ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
-
-
Constructor Summary
Constructors Constructor Description CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddGeneratedValuePlan(CompositeNestedGeneratedValueGenerator.GenerationPlan plan)Serializablegenerate(SharedSessionContractImplementor session, Object object)Generate a new identifier.voidinitialize(SqlStringGenerationContext context)Initializes this instance, in particular pre-generates SQL as necessary.voidregisterExportables(Database database)Register database objects used by this identifier generator, e.g.-
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
configure, supportsJdbcBatchInserts
-
-
-
-
Constructor Detail
-
CompositeNestedGeneratedValueGenerator
public CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator)
-
-
Method Detail
-
addGeneratedValuePlan
public void addGeneratedValuePlan(CompositeNestedGeneratedValueGenerator.GenerationPlan plan)
-
generate
public Serializable generate(SharedSessionContractImplementor session, Object object) throws HibernateException
Description copied from interface:IdentifierGeneratorGenerate a new identifier.- Specified by:
generatein 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
-
registerExportables
public void registerExportables(Database database)
Description copied from interface:IdentifierGeneratorRegister database objects used by this identifier generator, e.g. sequences, tables, etc.This method is called just once, after
IdentifierGenerator.configure(Type, Properties, ServiceRegistry).- Specified by:
registerExportablesin interfaceExportableProducer- Specified by:
registerExportablesin interfaceIdentifierGenerator- Parameters:
database- The database instance
-
initialize
public void initialize(SqlStringGenerationContext context)
Description copied from interface:IdentifierGeneratorInitializes this instance, in particular pre-generates SQL as necessary.This method is called after
IdentifierGenerator.registerExportables(Database), before first use.- Specified by:
initializein interfaceIdentifierGenerator- Parameters:
context- A context to help generate SQL strings
-
-