public class

CompositeNestedGeneratedValueGenerator

extends Object
implements Serializable IdentifierGenerator IdentifierGeneratorAggregator
java.lang.Object
   ↳ org.hibernate.id.CompositeNestedGeneratedValueGenerator

Class Overview

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.

Summary

Nested Classes
interface CompositeNestedGeneratedValueGenerator.GenerationContextLocator Contract for declaring how to locate the context for sub-value injection. 
interface CompositeNestedGeneratedValueGenerator.GenerationPlan Contract for performing the actual sub-value generation, usually injecting it into the determined context  
[Expand]
Inherited Constants
From interface org.hibernate.id.IdentifierGenerator
Public Constructors
CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator)
Public Methods
void addGeneratedValuePlan(CompositeNestedGeneratedValueGenerator.GenerationPlan plan)
Serializable generate(SessionImplementor session, Object object)
Generate a new identifier.
void registerPersistentGenerators(Map generatorMap)
Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.id.IdentifierGenerator
From interface org.hibernate.id.IdentifierGeneratorAggregator

Public Constructors

public CompositeNestedGeneratedValueGenerator (CompositeNestedGeneratedValueGenerator.GenerationContextLocator generationContextLocator)

Public Methods

public void addGeneratedValuePlan (CompositeNestedGeneratedValueGenerator.GenerationPlan plan)

public Serializable generate (SessionImplementor session, Object object)

Generate a new identifier.

Parameters
object the entity or toplevel collection for which the id is being generated
Returns
  • a new identifier

public void registerPersistentGenerators (Map generatorMap)

Register any sub generators which implement PersistentIdentifierGenerator by their generatorKey.

Parameters
generatorMap The map of generators.