Top Description Inners Fields Constructors Methods
org.hibernate.id

public Class CompositeNestedGeneratedValueGenerator

extends Object
implements IdentifierGenerator, Serializable, IdentifierGeneratorAggregator
Class Inheritance
All Implemented Interfaces
org.hibernate.id.IdentifierGeneratorAggregator, java.io.Serializable, org.hibernate.id.IdentifierGenerator
Imports
java.io.Serializable, java.util.ArrayList, .Iterator, .List, .Map, org.hibernate.HibernateException, org.hibernate.engine.SessionImplementor

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:

Most of the grunt work is done in org.hibernate.mapping.Component.

Author
Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
CompositeNestedGeneratedValueGenerator.GenerationContextLocator

Contract for declaring how to locate the context for sub-value injection.

public static interface
CompositeNestedGeneratedValueGenerator.GenerationPlan

Contract for performing the actual sub-value generation, usually injecting it into the determined context

Field Summary

Modifier and TypeField and Description
private final CompositeNestedGeneratedValueGenerator.GenerationContextLocator
private List<E>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public Serializable
generate(SessionImplementor session, Object
the entity or toplevel collection for which the id is being generated
object
)

Implements org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.
public void
registerPersistentGenerators(Map<K, V>
The map of generators.
generatorMap
)

Implements org.hibernate.id.IdentifierGeneratorAggregator.registerPersistentGenerators.

Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

generationContextLocatorback to summary
private final CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator
generationPlansback to summary
private List<E> generationPlans

Constructor Detail

CompositeNestedGeneratedValueGeneratorback to summary
public CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator)

Method Detail

addGeneratedValuePlanback to summary
public void addGeneratedValuePlan(CompositeNestedGeneratedValueGenerator.GenerationPlan plan)
generateback to summary
public Serializable generate(SessionImplementor session, Object object) throws HibernateException

Implements org.hibernate.id.IdentifierGenerator.generate.

Doc from org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.

Parameters
object:Object

the entity or toplevel collection for which the id is being generated

Returns:Serializable

a new identifier

registerPersistentGeneratorsback to summary
public void registerPersistentGenerators(Map<K, V> generatorMap)

Implements org.hibernate.id.IdentifierGeneratorAggregator.registerPersistentGenerators.

Doc from org.hibernate.id.IdentifierGeneratorAggregator.registerPersistentGenerators.

Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.

Parameters
generatorMap:Map<K, V>

The map of generators.

org.hibernate.id back to summary

public Interface CompositeNestedGeneratedValueGenerator.GenerationContextLocator

Known Direct Implementers
org.hibernate.mapping.Component.StandardGenerationContextLocator

Contract for declaring how to locate the context for sub-value injection.

Method Summary

Modifier and TypeMethod and Description
public Serializable

Returns:

The injection context
locateGenerationContext
(SessionImplementor
The current session
session
,
Object
The entity for which we are generating id
incomingObject
)

Given the incoming object, determine the context for injecting back its generated id sub-values.

Method Detail

locateGenerationContextback to summary
public Serializable locateGenerationContext(SessionImplementor session, Object incomingObject)

Given the incoming object, determine the context for injecting back its generated id sub-values.

Parameters
session:SessionImplementor

The current session

incomingObject:Object

The entity for which we are generating id

Returns:Serializable

The injection context

org.hibernate.id back to summary

public Interface CompositeNestedGeneratedValueGenerator.GenerationPlan

Known Direct Implementers
org.hibernate.mapping.Component.ValueGenerationPlan

Contract for performing the actual sub-value generation, usually injecting it into the determined context

Method Summary

Modifier and TypeMethod and Description
public void
execute(SessionImplementor
The current session
session
,
Object
The entity for which we are generating id
incomingObject
,
Object
The context into which the generated value can be injected
injectionContext
)

Execute the value generation.

public void
registerPersistentGenerators(Map<K, V>
The map of generators.
generatorMap
)

Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.

Method Detail

executeback to summary
public void execute(SessionImplementor session, Object incomingObject, Object injectionContext)

Execute the value generation.

Parameters
session:SessionImplementor

The current session

incomingObject:Object

The entity for which we are generating id

injectionContext:Object

The context into which the generated value can be injected

registerPersistentGeneratorsback to summary
public void registerPersistentGenerators(Map<K, V> generatorMap)

Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.

Parameters
generatorMap:Map<K, V>

The map of generators.