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:
<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.
@EmbeddedId)
and HBM mappings (<composite-id name="idAttributeName" class="PkClassName"/>)
@IdClass use case
and is only possible in annotations
Most of the grunt work is done in org..
| Modifier and Type | Class 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 |
| Modifier and Type | Field and Description |
|---|---|
| private final CompositeType | |
| private final CompositeNestedGeneratedValueGenerator. | |
| private final List |
| Access | Constructor and Description |
|---|---|
| public | CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator.
|
| Modifier and Type | Method 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. |
| public void | initialize(SqlStringGenerationContext
A context to help generate SQL strings context)Overrides default org. |
| public void | registerExportables(Database
The database instance database)Overrides default org. Implements org. |
| compositeType | back to summary |
|---|---|
| private final CompositeType compositeType | |
| generationContextLocator | back to summary |
|---|---|
| private final CompositeNestedGeneratedValueGenerator. | |
| generationPlans | back to summary |
|---|---|
| private final List<CompositeNestedGeneratedValueGenerator. | |
| CompositeNestedGeneratedValueGenerator | back to summary |
|---|---|
| public CompositeNestedGeneratedValueGenerator(CompositeNestedGeneratedValueGenerator. | |
| addGeneratedValuePlan | back to summary |
|---|---|
| public void addGeneratedValuePlan(CompositeNestedGeneratedValueGenerator. | |
| generate | back to summary |
|---|---|
| public Object generate(SharedSessionContractImplementor session, Object object) throws HibernateException Implements org. Doc from org. Generate a new identifier.
| |
| initialize | back to summary |
|---|---|
| public void initialize(SqlStringGenerationContext context) Overrides default org. Doc from org. Initializes this instance, in particular pre-generates SQL as necessary.
This method is called after
| |
| registerExportables | back to summary |
|---|---|
| public void registerExportables(Database database) Overrides default org. Implements org. Doc from org. Register database objects used by this identifier generator, for example, a sequence or tables.
This method is called just once, after
| |
| Modifier and Type | Method and Description |
|---|---|
| public Object | Returns: The injection contextThe 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. |
| locateGenerationContext | back to summary |
|---|---|
| public Object locateGenerationContext(SharedSessionContractImplementor session, Object incomingObject) Given the incoming object, determine the context for injecting back its generated id sub-values.
| |
| Modifier and Type | Method 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 | |
| public int | |
| public void | initialize(SqlStringGenerationContext
A context to help generate SQL strings context)Initializes this instance, in particular pre-generates SQL as necessary. |
| execute | back to summary |
|---|---|
| public Object execute(SharedSessionContractImplementor session, Object incomingObject) Execute the value generation.
| |
| getInjector | back to summary |
|---|---|
| public Setter getInjector() Returns the
| |
| getPropertyIndex | back to summary |
|---|---|
| public int getPropertyIndex() Returns the index of the generated property.
Used when the
| |
| initialize | back to summary |
|---|---|
| public void initialize(SqlStringGenerationContext context) Initializes this instance, in particular pre-generates SQL as necessary.
This method is called after
| |