Top Description Inners Fields Constructors Methods
org.hibernate.id

public Class CompositeNestedGeneratedValueGenerator

extends Object
implements IdentifierGenerator, StandardGenerator, IdentifierGeneratorAggregator, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.hibernate.id.IdentifierGeneratorAggregator, org.hibernate.boot.model.relational.ExportableProducer, org.hibernate.id.factory.spi.StandardGenerator, org.hibernate.id.IdentifierGenerator, org.hibernate.id.Configurable, org.hibernate.generator.BeforeExecutionGenerator, org.hibernate.generator.Generator
Annotations
@Internal
Imports
java.io.Serializable, java.util.ArrayList, .List, org.hibernate.HibernateException, .Internal, org.hibernate.boot.model.relational.Database, .ExportableProducer, .SqlStringGenerationContext, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.id.factory.spi.StandardGenerator, org.hibernate.property.access.spi.Setter, org.hibernate.type.CompositeType

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 CompositeType
private final CompositeNestedGeneratedValueGenerator.GenerationContextLocator
private final List<CompositeNestedGeneratedValueGenerator.GenerationPlan>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public Object
generate(SharedSessionContractImplementor
The session from which the request originates
session
,
Object
the entity or collection (idbag) for which the id is being generated
object
)

Implements org.hibernate.id.IdentifierGenerator.generate.

Generate a new identifier.
public void
initialize(SqlStringGenerationContext
A context to help generate SQL strings
context
)

Overrides default org.hibernate.id.IdentifierGenerator.initialize.

Initializes this instance, in particular pre-generates SQL as necessary.
public void
registerExportables(Database
The database instance
database
)

Overrides default org.hibernate.id.IdentifierGenerator.registerExportables.

Implements org.hibernate.boot.model.relational.ExportableProducer.registerExportables.

Register database objects used by this identifier generator, for example, a sequence or tables.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

compositeTypeback to summary
private final CompositeType compositeType
generationContextLocatorback to summary
private final CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator
generationPlansback to summary
private final List<CompositeNestedGeneratedValueGenerator.GenerationPlan> generationPlans

Constructor Detail

CompositeNestedGeneratedValueGeneratorback to summary
public CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator, CompositeType compositeType)

Method Detail

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

Implements org.hibernate.id.IdentifierGenerator.generate.

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

Generate a new identifier.

Parameters
session:SharedSessionContractImplementor

The session from which the request originates

object:Object

the entity or collection (idbag) for which the id is being generated

Returns:Object

a new identifier

Annotations
@Override
Exceptions
HibernateException:
Indicates trouble generating the identifier
initializeback to summary
public void initialize(SqlStringGenerationContext context)

Overrides default org.hibernate.id.IdentifierGenerator.initialize.

Doc from org.hibernate.id.IdentifierGenerator.initialize.

Initializes this instance, in particular pre-generates SQL as necessary.

This method is called after registerExportables(Database), and before first use.

Parameters
context:SqlStringGenerationContext

A context to help generate SQL strings

Annotations
@Override
registerExportablesback to summary
public void registerExportables(Database database)

Overrides default org.hibernate.id.IdentifierGenerator.registerExportables.

Implements org.hibernate.boot.model.relational.ExportableProducer.registerExportables.

Doc from org.hibernate.id.IdentifierGenerator.registerExportables.

Register database objects used by this identifier generator, for example, a sequence or tables.

This method is called just once, after configure(Type, Properties, ServiceRegistry).

Parameters
database:Database

The database instance

Annotations
@Override
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 Object

Returns:

The injection context
locateGenerationContext
(SharedSessionContractImplementor
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 Object locateGenerationContext(SharedSessionContractImplementor session, Object incomingObject)

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

Parameters
session:SharedSessionContractImplementor

The current session

incomingObject:Object

The entity for which we are generating id

Returns:Object

The injection context

org.hibernate.id back to summary

public Interface CompositeNestedGeneratedValueGenerator.GenerationPlan

extends ExportableProducer
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 Object
execute(SharedSessionContractImplementor
The current session
session
,
Object
The entity for which we are generating id
incomingObject
)

Execute the value generation.

public Setter
getInjector()

Returns the injector for the generated property.

public int
getPropertyIndex()

Returns the index of the generated property.

public void
initialize(SqlStringGenerationContext
A context to help generate SQL strings
context
)

Initializes this instance, in particular pre-generates SQL as necessary.

Inherited from org.hibernate.boot.model.relational.ExportableProducer:
registerExportables

Method Detail

executeback to summary
public Object execute(SharedSessionContractImplementor session, Object incomingObject)

Execute the value generation.

Parameters
session:SharedSessionContractImplementor

The current session

incomingObject:Object

The entity for which we are generating id

getInjectorback to summary
public Setter getInjector()

Returns the injector for the generated property. Used when the CompositeType is mutable.

See Also
getPropertyIndex()
getPropertyIndexback to summary
public int getPropertyIndex()

Returns the index of the generated property. Used when the CompositeType is not mutable.

See Also
getInjector()
initializeback to summary
public void initialize(SqlStringGenerationContext context)

Initializes this instance, in particular pre-generates SQL as necessary.

This method is called after registerExportables(Database), before first use.

Parameters
context:SqlStringGenerationContext

A context to help generate SQL strings