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, org.hibernate.boot.model.relational.ExportableProducer, java.io.Serializable, org.hibernate.id.IdentifierGenerator, org.hibernate.id.Configurable
Imports
java.io.Serializable, java.util.ArrayList, .List, .Properties, org.hibernate.HibernateException, org.hibernate.boot.model.relational.Database, .ExportableProducer, .SqlStringGenerationContext, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.service.ServiceRegistry, org.hibernate.type.Type

Deprecated

as a consequence of IdentifierGenerator being deprecated. See corresponding docs for further information.

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<CompositeNestedGeneratedValueGenerator.GenerationPlan>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public Serializable
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, e.g. sequences, tables, etc.

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

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

generationContextLocatorback to summary
private final CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator
generationPlansback to summary
private List<CompositeNestedGeneratedValueGenerator.GenerationPlan> 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(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:Serializable

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), 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, e.g. sequences, tables, etc.

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 Serializable

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 Serializable 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:Serializable

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 void
execute(SharedSessionContractImplementor
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 default 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 void execute(SharedSessionContractImplementor session, Object incomingObject, Object injectionContext)

Execute the value generation.

Parameters
session:SharedSessionContractImplementor

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

initializeback to summary
public default 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