Top Description Fields Constructors Methods
org.hibernate.metamodel.mapping.internal

public Class ManyToManyCollectionPart

extends AbstractEntityCollectionPart
implements EntityAssociationMapping, ParentTableGroupUseChecker
Class Inheritance
All Implemented Interfaces
org.hibernate.sql.ast.tree.from.LazyTableGroup.ParentTableGroupUseChecker, org.hibernate.metamodel.mapping.EntityAssociationMapping, org.hibernate.sql.ast.tree.from.TableGroupJoinProducer, org.hibernate.sql.ast.tree.from.TableGroupProducer, org.hibernate.metamodel.mapping.ModelPartContainer, org.hibernate.metamodel.mapping.ModelPart, org.hibernate.metamodel.mapping.MappingModelExpressible, org.hibernate.metamodel.mapping.Bindable, org.hibernate.metamodel.mapping.JdbcMappingContainer, org.hibernate.metamodel.mapping.Association, org.hibernate.sql.results.graph.Fetchable
Imports
java.util.Locale, java.util.function.Consumer, org.hibernate.annotations.NotFoundAction, org.hibernate.dialect.Dialect, org.hibernate.engine.spi.SharedSessionContractImplementor, org.hibernate.internal.util.StringHelper, org.hibernate.mapping.Collection, .Column, .IndexedCollection, .ManyToOne, .Map, .SimpleValue, .Value, org.hibernate.metamodel.mapping.AssociationKey, .AttributeMapping, .BasicEntityIdentifierMapping, .BasicValuedModelPart, .CompositeIdentifierMapping, .EmbeddableValuedModelPart, .EntityAssociationMapping, .EntityIdentifierMapping, .EntityMappingType, .ForeignKeyDescriptor, .JdbcMapping, .ManagedMappingType, .ModelPart, .ModelPartContainer, .PluralAttributeMapping, .SelectableConsumer, .SelectableMapping, .SelectableMappings, .ValuedModelPart, .VirtualModelPart, org.hibernate.persister.collection.BasicCollectionPersister, .CollectionPersister, org.hibernate.persister.collection.mutation.CollectionMutationTarget, org.hibernate.spi.NavigablePath, org.hibernate.sql.ast.SqlAstJoinType, org.hibernate.sql.ast.spi.SqlAliasBase, .SqlAstCreationState, org.hibernate.sql.ast.tree.from.LazyTableGroup, .TableGroup, .TableGroupJoin, .TableGroupProducer, .TableReference, org.hibernate.sql.ast.tree.predicate.Predicate, org.hibernate.type.EntityType

Entity-valued collection-part mapped through a join table. Models both ``` user( id, ... ) group( id, ... ) membership( user_fk, group_fk ) `Group.membership` table: membership key: group_fk element: user_fk ```
Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private ValuedModelPart
private ForeignKeyDescriptor

Constructor Summary

AccessConstructor and Description
public
ManyToManyCollectionPart(CollectionPart.Nature nature, Collection collectionBootDescriptor, CollectionPersister collectionDescriptor, EntityMappingType associatedEntityDescriptor, MappingModelCreationProcess creationProcess)

public
ManyToManyCollectionPart(CollectionPart.Nature nature, Collection collectionBootDescriptor, CollectionPersister collectionDescriptor, EntityMappingType associatedEntityDescriptor, NotFoundAction notFoundAction, MappingModelCreationProcess creationProcess)

Method Summary

Modifier and TypeMethod and Description
public <X, Y> int
breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Breaks down the domain value to its constituent JDBC values.
public boolean
private ForeignKeyDescriptor
createForeignKeyDescriptor(Value fkBootDescriptorSource, EntityType entityType, ModelPart fkTargetModelPart, MappingModelCreationProcess creationProcess, Dialect dialect)

private ForeignKeyDescriptor
createJoinTablePartForeignKey(String collectionTableName, ManyToOne elementBootDescriptor, MappingModelCreationProcess creationProcess)

public LazyTableGroup
createRootTableGroupJoin(NavigablePath
The NavigablePath to the join
navigablePath
,
TableGroup
The join's (L)eft-(H)and (S)ide
lhs
,
String explicitSourceAlias, SqlAliasBase
A specific SqlAliasBase to use. May be null indicating one should be created using the SqlAliasBaseGenerator from creationState
explicitSqlAliasBase
,
SqlAstJoinType
An explicit join-type. May be null to signal that the join is for an implicit path.
requestedJoinType
,
boolean fetched, Consumer<Predicate>
Consumer for additional predicates from the producer's mapping.
predicateConsumer
,
SqlAstCreationState creationState)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createRootTableGroupJoin.

Create the "join", but return a TableGroup.
private SimpleForeignKeyDescriptor
createSimpleForeignKeyDescriptor(Value fkBootDescriptorSource, EntityType entityType, MappingModelCreationProcess creationProcess, Dialect dialect, String fkKeyTableName, BasicValuedModelPart basicFkTargetPart)

public TableGroupJoin
createTableGroupJoin(NavigablePath
The NavigablePath to the join
navigablePath
,
TableGroup
The join's (L)eft-(H)and (S)ide
lhs
,
String explicitSourceAlias, SqlAliasBase
A specific SqlAliasBase to use. May be null indicating one should be created using the SqlAliasBaseGenerator from creationState
explicitSqlAliasBase
,
SqlAstJoinType
An explicit join-type. May be null to signal that the join is for an implicit path.
requestedJoinType
,
boolean fetched, boolean
Indicates there are explicit, additional predicates (from an SQM tree ON/WITH clause)
addsPredicate
,
SqlAstCreationState creationState)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createTableGroupJoin.

Create a TableGroupJoin.
public <X, Y> int
decompose(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.ModelPart.decompose.

Similar to breakDownJdbcValues(Object, int, Object, Object, JdbcValueBiConsumer, SharedSessionContractImplementor), but this method is supposed to be used for decomposing values for assignment expressions.
private ForeignKeyDescriptor
determineForeignKey(ForeignKeyDescriptor foreignKeyDescriptor, Value fkBootDescriptorSource, MappingModelCreationProcess creationProcess)

public ModelPart
public boolean
finishInitialization(CollectionPersister collectionDescriptor, Collection bootCollectionDescriptor, String fkTargetModelPartName, MappingModelCreationProcess creationProcess)

Implements org.hibernate.metamodel.mapping.internal.EntityCollectionPart.finishInitialization.

Perform any delayed initialization.
public void
public int
forEachSelectable(int offset, SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ModelPart.forEachSelectable, org.hibernate.metamodel.mapping.ValuedModelPart.forEachSelectable.

Visits each selectable mapping with the selectable index offset by the given value.
public void
public EntityCollectionPart.Cardinality
public String
getContainingTableExpression()

Implements org.hibernate.metamodel.mapping.ValuedModelPart.getContainingTableExpression.

The table which contains the columns mapped by this value
public SqlAstJoinType
public ForeignKeyDescriptor
getForeignKeyDescriptor()

Implements org.hibernate.metamodel.mapping.Association.getForeignKeyDescriptor.

The descriptor, allowing access to column(s), etc
public ModelPart
public JdbcMapping
public ModelPart
getKeyTargetMatchPart()

Implements org.hibernate.metamodel.mapping.EntityAssociationMapping.getKeyTargetMatchPart.

The model sub-part relative to the associated entity type that is the target of this association's foreign-key
public SelectableMapping
getSelectable(int columnIndex)

Implements org.hibernate.metamodel.mapping.SelectableMappings.getSelectable.

Get the selectable at the given position
public ForeignKeyDescriptor.Nature
getSideNature()

Implements org.hibernate.metamodel.mapping.Association.getSideNature.

Indicates which "side" of the foreign-key this association describes
public boolean
public boolean
public boolean
public boolean
isSimpleJoinPredicate(Predicate predicate)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.isSimpleJoinPredicate.

Returns whether the given predicate is a simple join predicate for this attribute.
protected AssociationKey
private static ValuedModelPart
resolveNamedTargetPart(String targetPartName, EntityMappingType entityMappingType, CollectionPersister collectionDescriptor)

Inherited from org.hibernate.metamodel.mapping.internal.AbstractEntityCollectionPart:
buildEagerCollectionFetchbuildEntityFetchJoinedcontainsTableReferencecreateDomainResultcreateTableGroupInternaldisassemblefindContainingEntityMappinggenerateFetchgetAssociatedEntityMappingTypegetCollectionDescriptorgetFetchableKeygetFetchableNamegetMappedFetchOptionsgetMappedTypegetNaturegetNavigableRolegetNotFoundActiongetNumberOfFetchablesgetSqlAliasStemgetStylegetTargetKeyPropertyNamesgetTimingincrementFetchDepthisOptionalisUnwrapProxytoString

Field Detail

fkTargetModelPartback to summary
private ValuedModelPart fkTargetModelPart
foreignKeyback to summary
private ForeignKeyDescriptor foreignKey

Constructor Detail

ManyToManyCollectionPartback to summary
public ManyToManyCollectionPart(CollectionPart.Nature nature, Collection collectionBootDescriptor, CollectionPersister collectionDescriptor, EntityMappingType associatedEntityDescriptor, MappingModelCreationProcess creationProcess)
ManyToManyCollectionPartback to summary
public ManyToManyCollectionPart(CollectionPart.Nature nature, Collection collectionBootDescriptor, CollectionPersister collectionDescriptor, EntityMappingType associatedEntityDescriptor, NotFoundAction notFoundAction, MappingModelCreationProcess creationProcess)

Method Detail

breakDownJdbcValuesback to summary
public <X, Y> int breakDownJdbcValues(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Implements org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Doc from org.hibernate.metamodel.mapping.ModelPart.breakDownJdbcValues.

Breaks down the domain value to its constituent JDBC values. Think of it as breaking the multi-dimensional array into a visitable flat array. Additionally, it passes through the values X and Y to the consumer. Returns the amount of jdbc types that have been visited.

Annotations
@Override
canUseParentTableGroupback to summary
public boolean canUseParentTableGroup(TableGroupProducer producer, NavigablePath navigablePath, ValuedModelPart valuedModelPart)

Implements org.hibernate.sql.ast.tree.from.LazyTableGroup.ParentTableGroupUseChecker.canUseParentTableGroup.

Annotations
@Override
createForeignKeyDescriptorback to summary
private ForeignKeyDescriptor createForeignKeyDescriptor(Value fkBootDescriptorSource, EntityType entityType, ModelPart fkTargetModelPart, MappingModelCreationProcess creationProcess, Dialect dialect)
createJoinTablePartForeignKeyback to summary
private ForeignKeyDescriptor createJoinTablePartForeignKey(String collectionTableName, ManyToOne elementBootDescriptor, MappingModelCreationProcess creationProcess)
createRootTableGroupJoinback to summary
public LazyTableGroup createRootTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAliasBase explicitSqlAliasBase, SqlAstJoinType requestedJoinType, boolean fetched, Consumer<Predicate> predicateConsumer, SqlAstCreationState creationState)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createRootTableGroupJoin.

Doc from org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createRootTableGroupJoin.

Create the "join", but return a TableGroup. Intended for creating sub-query correlations. E.g., given

    from SomeEntity e
    where exists (
        select 1
        from AnotherEntity a
        where e.association.attr = 1
    )
We call this for the `e.association` path.
Parameters
navigablePath:NavigablePath

The NavigablePath to the join

lhs:TableGroup

The join's (L)eft-(H)and (S)ide

explicitSqlAliasBase:SqlAliasBase

A specific SqlAliasBase to use. May be null indicating one should be created using the SqlAliasBaseGenerator from creationState

requestedJoinType:SqlAstJoinType

An explicit join-type. May be null to signal that the join is for an implicit path.

predicateConsumer:Consumer<Predicate>

Consumer for additional predicates from the producer's mapping.

Annotations
@Override
createSimpleForeignKeyDescriptorback to summary
private SimpleForeignKeyDescriptor createSimpleForeignKeyDescriptor(Value fkBootDescriptorSource, EntityType entityType, MappingModelCreationProcess creationProcess, Dialect dialect, String fkKeyTableName, BasicValuedModelPart basicFkTargetPart)
createTableGroupJoinback to summary
public TableGroupJoin createTableGroupJoin(NavigablePath navigablePath, TableGroup lhs, String explicitSourceAlias, SqlAliasBase explicitSqlAliasBase, SqlAstJoinType requestedJoinType, boolean fetched, boolean addsPredicate, SqlAstCreationState creationState)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createTableGroupJoin.

Doc from org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.createTableGroupJoin.

Create a TableGroupJoin.

Parameters
navigablePath:NavigablePath

The NavigablePath to the join

lhs:TableGroup

The join's (L)eft-(H)and (S)ide

explicitSqlAliasBase:SqlAliasBase

A specific SqlAliasBase to use. May be null indicating one should be created using the SqlAliasBaseGenerator from creationState

requestedJoinType:SqlAstJoinType

An explicit join-type. May be null to signal that the join is for an implicit path.

addsPredicate:boolean

Indicates there are explicit, additional predicates (from an SQM tree ON/WITH clause)

Annotations
@Override
decomposeback to summary
public <X, Y> int decompose(Object domainValue, int offset, X x, Y y, ModelPart.JdbcValueBiConsumer<X, Y> valueConsumer, SharedSessionContractImplementor session)

Overrides default org.hibernate.metamodel.mapping.ModelPart.decompose.

Doc from org.hibernate.metamodel.mapping.ModelPart.decompose.

Similar to breakDownJdbcValues(Object, int, Object, Object, JdbcValueBiConsumer, SharedSessionContractImplementor), but this method is supposed to be used for decomposing values for assignment expressions. Returns the amount of jdbc types that have been visited.

Annotations
@Override
determineForeignKeyback to summary
private ForeignKeyDescriptor determineForeignKey(ForeignKeyDescriptor foreignKeyDescriptor, Value fkBootDescriptorSource, MappingModelCreationProcess creationProcess)
findSubPartback to summary
public ModelPart findSubPart(String name, EntityMappingType targetType)

Overrides default org.hibernate.metamodel.mapping.EntityValuedModelPart.findSubPart.

Implements org.hibernate.metamodel.mapping.ModelPartContainer.findSubPart.

Annotations
@Override
finishInitializationback to summary
public boolean finishInitialization(CollectionPersister collectionDescriptor, Collection bootCollectionDescriptor, String fkTargetModelPartName, MappingModelCreationProcess creationProcess)

Implements org.hibernate.metamodel.mapping.internal.EntityCollectionPart.finishInitialization.

Doc from org.hibernate.metamodel.mapping.internal.EntityCollectionPart.finishInitialization.

Perform any delayed initialization.

The initialization is considered successful if the result is true. It is considered unsuccessful if the result is false or an exception is thrown. Unsuccessful initializations are generally retried "later", to allow waiting for model-parts being available e.g.

If the exception is something that will just never succeed, consider throwing an exception with the NonTransientException marker to allow the creation process to stop immediately

Annotations
@Override
forEachInsertableback to summary
public void forEachInsertable(SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ValuedModelPart.forEachInsertable.

Annotations
@Override
forEachSelectableback to summary
public int forEachSelectable(int offset, SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ModelPart.forEachSelectable, org.hibernate.metamodel.mapping.ValuedModelPart.forEachSelectable.

Doc from org.hibernate.metamodel.mapping.ModelPart.forEachSelectable.

Visits each selectable mapping with the selectable index offset by the given value. Returns the amount of jdbc types that have been visited.

Annotations
@Override
forEachUpdatableback to summary
public void forEachUpdatable(SelectableConsumer consumer)

Overrides default org.hibernate.metamodel.mapping.ValuedModelPart.forEachUpdatable.

Annotations
@Override
getCardinalityback to summary
public EntityCollectionPart.Cardinality getCardinality()

Implements org.hibernate.metamodel.mapping.internal.EntityCollectionPart.getCardinality.

Annotations
@Override
getContainingTableExpressionback to summary
public String getContainingTableExpression()

Implements org.hibernate.metamodel.mapping.ValuedModelPart.getContainingTableExpression.

Doc from org.hibernate.metamodel.mapping.ValuedModelPart.getContainingTableExpression.

The table which contains the columns mapped by this value

Annotations
@Override
getDefaultSqlAstJoinTypeback to summary
public SqlAstJoinType getDefaultSqlAstJoinType(TableGroup parentTableGroup)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.getDefaultSqlAstJoinType.

Annotations
@Override
getForeignKeyDescriptorback to summary
public ForeignKeyDescriptor getForeignKeyDescriptor()

Implements org.hibernate.metamodel.mapping.Association.getForeignKeyDescriptor.

Doc from org.hibernate.metamodel.mapping.Association.getForeignKeyDescriptor.

The descriptor, allowing access to column(s), etc

Annotations
@Override
getInclusionCheckPartback to summary
public ModelPart getInclusionCheckPart()

Overrides default org.hibernate.metamodel.mapping.CollectionPart.getInclusionCheckPart.

Annotations
@Override
getJdbcMappingback to summary
public JdbcMapping getJdbcMapping(final int index)

Implements org.hibernate.metamodel.mapping.JdbcMappingContainer.getJdbcMapping.

Annotations
@Override
getKeyTargetMatchPartback to summary
public ModelPart getKeyTargetMatchPart()

Implements org.hibernate.metamodel.mapping.EntityAssociationMapping.getKeyTargetMatchPart.

Doc from org.hibernate.metamodel.mapping.EntityAssociationMapping.getKeyTargetMatchPart.

The model sub-part relative to the associated entity type that is the target of this association's foreign-key

Annotations
@Override
getSelectableback to summary
public SelectableMapping getSelectable(int columnIndex)

Implements org.hibernate.metamodel.mapping.SelectableMappings.getSelectable.

Doc from org.hibernate.metamodel.mapping.SelectableMappings.getSelectable.

Get the selectable at the given position

Annotations
@Override
getSideNatureback to summary
public ForeignKeyDescriptor.Nature getSideNature()

Implements org.hibernate.metamodel.mapping.Association.getSideNature.

Doc from org.hibernate.metamodel.mapping.Association.getSideNature.

Indicates which "side" of the foreign-key this association describes

Annotations
@Override
hasPartitionedSelectionMappingback to summary
public boolean hasPartitionedSelectionMapping()

Implements org.hibernate.metamodel.mapping.ModelPart.hasPartitionedSelectionMapping.

Annotations
@Override
isFkOptimizationAllowedback to summary
public boolean isFkOptimizationAllowed()

Implements org.hibernate.metamodel.mapping.EntityAssociationMapping.isFkOptimizationAllowed.

Annotations
@Override
isReferenceToPrimaryKeyback to summary
public boolean isReferenceToPrimaryKey()

Implements org.hibernate.metamodel.mapping.EntityAssociationMapping.isReferenceToPrimaryKey.

Annotations
@Override
isSimpleJoinPredicateback to summary
public boolean isSimpleJoinPredicate(Predicate predicate)

Implements org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.isSimpleJoinPredicate.

Doc from org.hibernate.sql.ast.tree.from.TableGroupJoinProducer.isSimpleJoinPredicate.

Returns whether the given predicate is a simple join predicate for this attribute. This is useful to understand if a predicate has additional conjunctions other than the FK related predicate.

Annotations
@Override
resolveFetchAssociationKeyback to summary
protected AssociationKey resolveFetchAssociationKey()

Implements abstract org.hibernate.metamodel.mapping.internal.AbstractEntityCollectionPart.resolveFetchAssociationKey.

Annotations
@Override
resolveNamedTargetPartback to summary
private static ValuedModelPart resolveNamedTargetPart(String targetPartName, EntityMappingType entityMappingType, CollectionPersister collectionDescriptor)