Package org.hibernate.id
Class CompositeNestedGeneratedValueGenerator
java.lang.Object
org.hibernate.id.CompositeNestedGeneratedValueGenerator
- All Implemented Interfaces:
Serializable
,ExportableProducer
,BeforeExecutionGenerator
,Generator
,Configurable
,IdentifierGenerator
,IdentifierGeneratorAggregator
@Internal
public class CompositeNestedGeneratedValueGenerator
extends Object
implements IdentifierGenerator, IdentifierGeneratorAggregator, Serializable
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@IdClass
usage, 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
@IdClass
use case and is only possible in annotations
Most of the grunt work is done in Component
.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Contract for declaring how to locate the context for sub-value injection.static interface
Contract for performing the actual sub-value generation, usually injecting it into the determined context -
Field Summary
Fields inherited from interface org.hibernate.id.IdentifierGenerator
CONTRIBUTOR_NAME, ENTITY_NAME, GENERATOR_NAME, JPA_ENTITY_NAME
-
Constructor Summary
ConstructorsConstructorDescriptionCompositeNestedGeneratedValueGenerator
(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator, CompositeType compositeType) -
Method Summary
Modifier and TypeMethodDescriptionvoid
generate
(SharedSessionContractImplementor session, Object object) Generate a new identifier.void
initialize
(SqlStringGenerationContext context) Initializes this instance, pre-generating SQL if necessary.void
registerExportables
(Database database) Register database objects used by this identifier generator, for example, a sequence or tables.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
configure
Methods inherited from interface org.hibernate.generator.Generator
allowAssignedIdentifiers, allowMutation, generatedBeforeExecution, generatedOnExecution, generatesOnInsert, generatesOnUpdate, generatesSometimes
Methods inherited from interface org.hibernate.id.IdentifierGenerator
configure, generate, getEventTypes
-
Constructor Details
-
CompositeNestedGeneratedValueGenerator
public CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator, CompositeType compositeType)
-
-
Method Details
-
addGeneratedValuePlan
-
registerExportables
Description copied from interface:IdentifierGenerator
Register database objects used by this identifier generator, for example, a sequence or tables.This method is called just once, after
Configurable.configure(GeneratorCreationContext, Properties)
.- Specified by:
registerExportables
in interfaceExportableProducer
- Specified by:
registerExportables
in interfaceIdentifierGenerator
- Parameters:
database
- The database instance
-
initialize
Description copied from interface:Configurable
Initializes this instance, pre-generating SQL if necessary.If this instance also implements
ExportableProducer
, then this method is always called afterExportableProducer.registerExportables(Database)
, and before first use.- Specified by:
initialize
in interfaceConfigurable
- Parameters:
context
- A context to help generate SQL strings
-