From 1a9079006c6a492ed6ad4bb957de09e9fc740737 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Wed, 31 Mar 2021 11:21:51 -0500 Subject: [PATCH] Rename SelectionMapping(s) to SelectableMapping(s) and related changes --- .../ast/internal/AbstractNaturalIdLoader.java | 20 ++-- .../ast/internal/CompoundNaturalIdLoader.java | 6 +- .../internal/DatabaseSnapshotExecutor.java | 2 +- .../ast/internal/LoaderSelectBuilder.java | 8 +- .../ast/internal/SimpleNaturalIdLoader.java | 6 +- .../AbstractCompositeIdentifierMapping.java | 16 +-- .../mapping/BasicValuedModelPart.java | 2 +- .../mapping/EmbeddableMappingType.java | 31 +++--- .../mapping/EmbeddableValuedModelPart.java | 4 +- .../metamodel/mapping/EntityMappingType.java | 3 +- .../mapping/ForeignKeyDescriptor.java | 18 +-- .../metamodel/mapping/MappingModelHelper.java | 2 +- .../metamodel/mapping/ModelPart.java | 9 +- ...nConsumer.java => SelectableConsumer.java} | 25 ++++- ...ionMapping.java => SelectableMapping.java} | 4 +- .../metamodel/mapping/SelectableMappings.java | 58 ++++++++++ .../metamodel/mapping/SelectionMappings.java | 33 ------ .../mapping/internal/AbstractDomainPath.java | 6 +- .../mapping/internal/AnyKeyPart.java | 4 +- .../BasicEntityIdentifierMappingImpl.java | 4 +- .../internal/BasicValuedCollectionPart.java | 36 +++--- .../BasicValuedSingularAttributeMapping.java | 4 +- .../internal/CompoundNaturalIdMapping.java | 7 +- .../internal/EmbeddedAttributeMapping.java | 8 +- .../internal/EmbeddedCollectionPart.java | 2 +- .../EmbeddedForeignKeyDescriptor.java | 64 ++++++----- .../internal/EntityCollectionPart.java | 9 +- .../internal/EntityRowIdMappingImpl.java | 4 +- .../internal/EntityVersionMappingImpl.java | 2 - .../internal/MappingModelCreationHelper.java | 42 +++---- .../internal/PluralAttributeMappingImpl.java | 6 +- ...ngImpl.java => SelectableMappingImpl.java} | 10 +- ...sImpl.java => SelectableMappingsImpl.java} | 50 ++++----- .../internal/SimpleForeignKeyDescriptor.java | 104 +++++++++--------- .../internal/SimpleNaturalIdMapping.java | 6 +- ...ngs.java => SingleSelectableMappings.java} | 17 ++- .../internal/ToOneAttributeMapping.java | 6 +- .../entity/AbstractEntityPersister.java | 8 +- .../internal/MatchingIdSelectionHelper.java | 4 +- .../internal/cte/CteDeleteHandler.java | 37 +++---- .../internal/cte/CteUpdateHandler.java | 16 ++- .../idtable/ExecuteWithIdTableHelper.java | 2 +- .../idtable/ExecuteWithoutIdTableHelper.java | 2 +- .../mutation/internal/idtable/IdTable.java | 2 +- .../RestrictedDeleteExecutionDelegate.java | 6 +- .../idtable/UpdateExecutionDelegate.java | 4 +- .../DisjunctionRestrictionProducer.java | 6 +- .../InPredicateRestrictionProducer.java | 6 +- .../internal/inline/InlineDeleteHandler.java | 4 +- .../inline/MatchingIdRestrictionProducer.java | 4 +- ...leValueConstructorRestrictionProducer.java | 4 +- .../sqm/sql/BaseSqmToSqlAstConverter.java | 50 ++++----- .../EntityValuedPathInterpretation.java | 12 +- .../hibernate/sql/ast/tree/cte/CteTable.java | 2 +- .../ast/tree/expression/ColumnReference.java | 18 +-- .../orm/test/mapping/SmokeTests.java | 4 +- .../manytoone/ManyToOneJoinTableTest.java | 16 +-- .../test/mapping/manytoone/ManyToOneTest.java | 4 +- ...ntityWithBidirectionalAssociationTest.java | 8 +- ...BidirectionalJoinTableAssociationTest.java | 8 +- .../EntityWithOneToOneJoinTableTest.java | 4 +- ...tityWithOneToOneSharingPrimaryKeyTest.java | 4 +- .../readwrite/AbstractReadWriteTests.java | 3 +- 63 files changed, 443 insertions(+), 433 deletions(-) rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/{SelectionConsumer.java => SelectableConsumer.java} (55%) rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/{SelectionMapping.java => SelectableMapping.java} (86%) create mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMappings.java delete mode 100644 hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMappings.java rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/{SelectionMappingImpl.java => SelectableMappingImpl.java} (91%) rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/{SelectionMappingsImpl.java => SelectableMappingsImpl.java} (61%) rename hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/{SingleSelectionMappings.java => SingleSelectableMappings.java} (77%) diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractNaturalIdLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractNaturalIdLoader.java index 736badba97..a3e37e2713 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractNaturalIdLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/AbstractNaturalIdLoader.java @@ -28,7 +28,7 @@ import org.hibernate.loader.ast.spi.NaturalIdLoader; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.NaturalIdMapping; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.query.NavigablePath; import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryParameterBindings; @@ -278,29 +278,29 @@ public abstract class AbstractNaturalIdLoader implements NaturalIdLoader { */ protected Expression resolveColumnReference( TableGroup rootTableGroup, - SelectionMapping selectionMapping, + SelectableMapping selectableMapping, SqlExpressionResolver sqlExpressionResolver, SessionFactoryImplementor sessionFactory) { - final TableReference tableReference = rootTableGroup.getTableReference( selectionMapping.getContainingTableExpression() ); + final TableReference tableReference = rootTableGroup.getTableReference( selectableMapping.getContainingTableExpression() ); if ( tableReference == null ) { throw new IllegalStateException( String.format( Locale.ROOT, "Unable to locate TableReference for `%s` : %s", - selectionMapping.getContainingTableExpression(), + selectableMapping.getContainingTableExpression(), rootTableGroup ) ); } return sqlExpressionResolver.resolveSqlExpression( - SqlExpressionResolver.createColumnReferenceKey( tableReference, selectionMapping.getSelectionExpression() ), + SqlExpressionResolver.createColumnReferenceKey( tableReference, selectableMapping.getSelectionExpression() ), (processingState) -> new ColumnReference( tableReference, - selectionMapping.getSelectionExpression(), - selectionMapping.isFormula(), - selectionMapping.getCustomReadExpression(), - selectionMapping.getCustomWriteExpression(), - selectionMapping.getJdbcMapping(), + selectableMapping.getSelectionExpression(), + selectableMapping.isFormula(), + selectableMapping.getCustomReadExpression(), + selectableMapping.getCustomWriteExpression(), + selectableMapping.getJdbcMapping(), sessionFactory ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CompoundNaturalIdLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CompoundNaturalIdLoader.java index 8a2cda9bc1..af9ef63ece 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CompoundNaturalIdLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/CompoundNaturalIdLoader.java @@ -52,11 +52,11 @@ public class CompoundNaturalIdLoader extends AbstractNaturalIdLoader { if ( bindValue == null ) { final List naturalIdAttributes = naturalIdMapping().getNaturalIdAttributes(); for ( int i = 0; i < naturalIdAttributes.size(); i++ ) { - naturalIdAttributes.get( i ).forEachSelection( - (selectionIndex, selectionMapping) -> { + naturalIdAttributes.get( i ).forEachSelectable( + (index, selectable) -> { final Expression columnRef = resolveColumnReference( rootTableGroup, - selectionMapping, + selectable, sqlExpressionResolver, factory ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java index 3c6572becb..3d3a8333fc 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java @@ -111,7 +111,7 @@ class DatabaseSnapshotExecutor { new QueryLiteral<>( null, IntegerType.INSTANCE ).createDomainResult( null, state ) ); - entityDescriptor.getIdentifierMapping().forEachSelection( + entityDescriptor.getIdentifierMapping().forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = rootTableGroup.resolveTableReference( selection.getContainingTableExpression() ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java index 3aecea607c..7161f7ef64 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java @@ -470,7 +470,7 @@ public class LoaderSelectBuilder { final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver(); if ( numberColumns == 1 ) { - modelPart.forEachSelection( + modelPart.forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = rootTableGroup.resolveTableReference( selection.getContainingTableExpression() ); @@ -510,7 +510,7 @@ public class LoaderSelectBuilder { else { final List columnReferences = new ArrayList<>( numberColumns ); - modelPart.forEachSelection( + modelPart.forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = rootTableGroup.resolveTableReference( selection.getContainingTableExpression() ); columnReferences.add( @@ -906,7 +906,7 @@ public class LoaderSelectBuilder { } else { final List columnReferences = new ArrayList<>( jdbcTypeCount ); - fkDescriptor.forEachSelection( + fkDescriptor.forEachSelectable( (columnIndex, selection) -> columnReferences.add( (ColumnReference) sqlAstCreationState.getSqlExpressionResolver() @@ -964,7 +964,7 @@ public class LoaderSelectBuilder { final SqlExpressionResolver sqlExpressionResolver = creationState.getSqlExpressionResolver(); - fkDescriptor.visitTargetColumns( + fkDescriptor.visitTargetSelectables( (valuesPosition, selection) -> { // for each column, resolve a SqlSelection and add it to the sub-query select-clause final TableReference tableReference = ownerTableGroup.resolveTableReference( selection.getContainingTableExpression() ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SimpleNaturalIdLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SimpleNaturalIdLoader.java index a0b59d9884..dbce7617aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SimpleNaturalIdLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SimpleNaturalIdLoader.java @@ -67,11 +67,11 @@ public class SimpleNaturalIdLoader extends AbstractNaturalIdLoader { LoaderSqlAstCreationState sqlAstCreationState, SharedSessionContractImplementor session) { if ( bindValue == null ) { - naturalIdMapping().getAttribute().forEachSelection( - (selectionIndex, selectionMapping) -> { + naturalIdMapping().getAttribute().forEachSelectable( + (index, selectable) -> { final Expression columnReference = resolveColumnReference( rootTableGroup, - selectionMapping, + selectable, sqlAstCreationState.getSqlExpressionResolver(), session.getFactory() ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractCompositeIdentifierMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractCompositeIdentifierMapping.java index 55c264bd4c..1eb6d1173d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractCompositeIdentifierMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractCompositeIdentifierMapping.java @@ -17,8 +17,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMappings; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMappings; import org.hibernate.metamodel.mapping.CompositeIdentifierMapping; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; @@ -117,20 +117,20 @@ public abstract class AbstractCompositeIdentifierMapping } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { int span = 0; final List attributes = getAttributes(); for ( int i = 0; i < attributes.size(); i++ ) { final SingularAttributeMapping attribute = attributes.get( i ); if ( attribute instanceof ToOneAttributeMapping ) { final ToOneAttributeMapping associationAttributeMapping = (ToOneAttributeMapping) attribute; - span += associationAttributeMapping.getForeignKeyDescriptor().visitReferringColumns( + span += associationAttributeMapping.getForeignKeyDescriptor().visitReferringSelectables( span + offset, consumer ); } else { - span += attribute.forEachSelection( span + offset, consumer ); + span += attribute.forEachSelectable( span + offset, consumer ); } } return span; @@ -226,10 +226,10 @@ public abstract class AbstractCompositeIdentifierMapping Clause clause, SqmToSqlAstConverter walker, SqlAstCreationState sqlAstCreationState) { - final SelectionMappings selectionMappings = getEmbeddableTypeDescriptor(); - final List columnReferences = CollectionHelper.arrayList( selectionMappings.getJdbcTypeCount() ); + final SelectableMappings selectableMappings = getEmbeddableTypeDescriptor(); + final List columnReferences = CollectionHelper.arrayList( selectableMappings.getJdbcTypeCount() ); final TableReference defaultTableReference = tableGroup.resolveTableReference( getContainingTableExpression() ); - getEmbeddableTypeDescriptor().forEachSelection( + getEmbeddableTypeDescriptor().forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = selection.getContainingTableExpression().equals( defaultTableReference.getTableExpression() ) ? defaultTableReference diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java index 900577c621..cb601f1b24 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java @@ -11,7 +11,7 @@ import org.hibernate.sql.results.graph.Fetchable; /** * @author Steve Ebersole */ -public interface BasicValuedModelPart extends BasicValuedMapping, ModelPart, Fetchable, SelectionMapping { +public interface BasicValuedModelPart extends BasicValuedMapping, ModelPart, Fetchable, SelectableMapping { @Override default MappingType getPartMappingType() { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java index 1678e16216..82cd169f34 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java @@ -37,14 +37,13 @@ import org.hibernate.mapping.Table; import org.hibernate.metamodel.mapping.internal.DiscriminatedAssociationAttributeMapping; import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper; import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess; -import org.hibernate.metamodel.mapping.internal.SelectionMappingsImpl; +import org.hibernate.metamodel.mapping.internal.SelectableMappingsImpl; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.spi.EmbeddableRepresentationStrategy; import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.property.access.spi.PropertyAccess; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.Template; import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.results.graph.DomainResult; @@ -65,7 +64,7 @@ import org.hibernate.type.spi.TypeConfiguration; /** * @author Steve Ebersole */ -public class EmbeddableMappingType implements ManagedMappingType, SelectionMappings { +public class EmbeddableMappingType implements ManagedMappingType, SelectableMappings { public static EmbeddableMappingType from( Component bootDescriptor, @@ -136,7 +135,7 @@ public class EmbeddableMappingType implements ManagedMappingType, SelectionMappi private final SessionFactoryImplementor sessionFactory; private final List attributeMappings = new ArrayList<>(); - private SelectionMappings selectionMappings; + private SelectableMappings selectableMappings; private final EmbeddableValuedModelPart valueMapping; private NavigableRole embeddedRole; @@ -428,7 +427,7 @@ public class EmbeddableMappingType implements ManagedMappingType, SelectionMappi } private boolean initColumnMappings() { - this.selectionMappings = SelectionMappingsImpl.from( this ); + this.selectableMappings = SelectableMappingsImpl.from( this ); return true; } @@ -503,27 +502,25 @@ public class EmbeddableMappingType implements ManagedMappingType, SelectionMappi } @Override - public SelectionMapping getSelectionMapping(int columnIndex) { - return selectionMappings.getSelectionMapping( columnIndex ); + public SelectableMapping getSelectable(int columnIndex) { + return selectableMappings.getSelectable( columnIndex ); } @Override public int getJdbcTypeCount() { - return selectionMappings.getJdbcTypeCount(); + return selectableMappings.getJdbcTypeCount(); } @Override public List getJdbcMappings() { - return selectionMappings.getJdbcMappings(); + return selectableMappings.getJdbcMappings(); } @Override public int forEachJdbcType(int offset, IndexedConsumer action) { - return selectionMappings.forEachSelection( + return selectableMappings.forEachSelectable( offset, - (selectionIndex, selectionMapping) -> { - action.accept( selectionIndex, selectionMapping.getJdbcMapping() ); - } + (index, selectable) -> action.accept( index, selectable.getJdbcMapping() ) ); } @@ -597,13 +594,13 @@ public class EmbeddableMappingType implements ManagedMappingType, SelectionMappi } @Override - public int forEachSelection(SelectionConsumer consumer) { - return selectionMappings.forEachSelection( 0, consumer ); + public void forEachSelectable(SelectableConsumer consumer) { + selectableMappings.forEachSelectable( 0, consumer ); } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { - return selectionMappings.forEachSelection( offset, consumer ); + public int forEachSelectable(int offset, SelectableConsumer consumer) { + return selectableMappings.forEachSelectable( offset, consumer ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java index 73868d90a8..3f0fa81f2f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java @@ -59,8 +59,8 @@ public interface EmbeddableValuedModelPart extends ModelPart, Fetchable, Fetchab } @Override - default int forEachSelection(int offset, SelectionConsumer consumer) { - return getEmbeddableTypeDescriptor().forEachSelection( offset, consumer ); + default int forEachSelectable(int offset, SelectableConsumer consumer) { + return getEmbeddableTypeDescriptor().forEachSelectable( offset, consumer ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java index f63cfa468f..131bf0e634 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java @@ -8,7 +8,6 @@ package org.hibernate.metamodel.mapping; import java.util.Collection; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; @@ -198,7 +197,7 @@ public interface EntityMappingType extends ManagedMappingType, EntityValuedModel } interface ConstraintOrderedTableConsumer { - void consume(String tableExpression, Supplier> tableKeyColumnVisitationSupplier); + void consume(String tableExpression, Supplier> tableKeyColumnVisitationSupplier); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java index 494fe2a481..76cd082e0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java @@ -66,22 +66,22 @@ public interface ForeignKeyDescriptor extends VirtualModelPart { * Visits the FK "referring" columns */ @Override - default int forEachSelection(int offset, SelectionConsumer consumer) { - return visitReferringColumns( offset, consumer ); + default int forEachSelectable(int offset, SelectableConsumer consumer) { + return visitReferringSelectables( offset, consumer ); } Object getAssociationKeyFromTarget(Object targetObject, SharedSessionContractImplementor session); - int visitReferringColumns(int offset, SelectionConsumer consumer); + int visitReferringSelectables(int offset, SelectableConsumer consumer); - int visitTargetColumns(int offset, SelectionConsumer consumer); - - default int visitReferringColumns(SelectionConsumer consumer) { - return visitReferringColumns( 0, consumer ); + default int visitReferringSelectables(SelectableConsumer consumer) { + return visitReferringSelectables( 0, consumer ); } - default int visitTargetColumns(SelectionConsumer consumer) { - return visitTargetColumns( 0, consumer ); + int visitTargetSelectables(int offset, SelectableConsumer consumer); + + default int visitTargetSelectables(SelectableConsumer consumer) { + return visitTargetSelectables( 0, consumer ); } AssociationKey getAssociationKey(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/MappingModelHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/MappingModelHelper.java index f3044daed0..262f178d87 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/MappingModelHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/MappingModelHelper.java @@ -29,7 +29,7 @@ public class MappingModelHelper { if ( modelPart instanceof EmbeddableValuedModelPart ) { final List columnReferences = new ArrayList<>( jdbcTypeCount ); - modelPart.forEachSelection( + modelPart.forEachSelectable( (columnIndex, selection) -> { final ColumnReference colRef; if ( sqlExpressionResolver == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java index b89c20c526..9f2245eafc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java @@ -6,7 +6,6 @@ */ package org.hibernate.metamodel.mapping; -import java.util.List; import java.util.Objects; import java.util.function.BiConsumer; @@ -97,17 +96,17 @@ public interface ModelPart extends MappingModelExpressable { throw new NotYetImplementedFor6Exception( getClass() ); } - default int forEachSelection(SelectionConsumer consumer) { - return forEachSelection( 0, consumer ); + default void forEachSelectable(SelectableConsumer consumer) { + forEachSelectable( 0, consumer ); } - default int forEachSelection(int offset, SelectionConsumer consumer) { + default int forEachSelectable(int offset, SelectableConsumer consumer) { return 0; } @FunctionalInterface interface JdbcValueConsumer { - void consume(Object value, SelectionMapping jdbcValueMapping); + void consume(Object value, SelectableMapping jdbcValueMapping); } void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionConsumer.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableConsumer.java similarity index 55% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionConsumer.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableConsumer.java index ab276caa7d..2292522b5c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableConsumer.java @@ -7,17 +7,30 @@ package org.hibernate.metamodel.mapping; /** - * Consumer used to visit columns for a given model part + * Consumer used to visit selectable (column/formula) mappings * * @author Steve Ebersole */ @FunctionalInterface -public interface SelectionConsumer { - - void accept(int selectionIndex, SelectionMapping selectionMapping); +public interface SelectableConsumer { + /** + * Accept the selectable mapping. `selectIndex` is its position, + * the meaning of which depends on the impl and whether + * {@link SelectableMappings#forEachSelectable(SelectableConsumer)} or + * {@link SelectableMappings#forEachSelectable(int, SelectableConsumer)} + * was used + */ + void accept(int selectionIndex, SelectableMapping selectableMapping); + /** + * Simple form allowing visitation over a number of column names within a + * table. + * + * Very limited functionality in terms of the visited SelectableMappings + * will not have any defined JdbcMapping, etc + */ default void accept(String tableName, String[] columnNames) { - class SelectionMappingIterator implements SelectionMapping { + class SelectableMappingIterator implements SelectableMapping { private int index; @@ -52,7 +65,7 @@ public interface SelectionConsumer { } } for ( - SelectionMappingIterator iterator = new SelectionMappingIterator(); + SelectableMappingIterator iterator = new SelectableMappingIterator(); iterator.index < columnNames.length; iterator.index++ ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMapping.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMapping.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMapping.java index 846e052ced..f1f409d8ca 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMapping.java @@ -7,11 +7,11 @@ package org.hibernate.metamodel.mapping; /** - * A column mapping. + * Mapping of a selectable (column/formula) * * @author Christian Beikov */ -public interface SelectionMapping { +public interface SelectableMapping { String getContainingTableExpression(); String getSelectionExpression(); String getCustomReadExpression(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMappings.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMappings.java new file mode 100644 index 0000000000..497cad3b19 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectableMappings.java @@ -0,0 +1,58 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.metamodel.mapping; + +import java.util.ArrayList; +import java.util.List; + +/** + * A container for multiple selectable (column, formula) mappings. + * + * @author Christian Beikov + */ +public interface SelectableMappings { + /** + * The number of selectables + */ + int getJdbcTypeCount(); + + /** + * Get the selectable at the given position + */ + SelectableMapping getSelectable(int columnIndex); + + /** + * Visit each contained selectable mapping. + * + * As the selectables are iterated, we call `SelectionConsumer` + * passing along `offset` + our current iteration index. + * + * The return is the number of selectables we directly contain + * + * @see SelectableConsumer#accept(int, org.hibernate.metamodel.mapping.SelectableMapping) + */ + int forEachSelectable(int offset, SelectableConsumer consumer); + + /** + * Same as {@link #forEachSelectable(int, SelectableConsumer)}, with + * an implicit offset of `0` + */ + default void forEachSelectable(SelectableConsumer consumer) { + forEachSelectable( 0, consumer ); + } + + /** + * Obtain the JdbcMappings for the underlying selectable mappings + * + * @see SelectableMapping#getJdbcMapping() + */ + default List getJdbcMappings() { + final List results = new ArrayList<>(); + forEachSelectable( (index, selection) -> results.add( selection.getJdbcMapping() ) ); + return results; + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMappings.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMappings.java deleted file mode 100644 index 847914299a..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/SelectionMappings.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.metamodel.mapping; - -import java.util.ArrayList; -import java.util.List; - -/** - * A container for multiple column mappings. - * - * @author Christian Beikov - */ -public interface SelectionMappings { - SelectionMapping getSelectionMapping(int columnIndex); - - int getJdbcTypeCount(); - - int forEachSelection(int offset, SelectionConsumer consumer); - - default int forEachSelection(SelectionConsumer consumer) { - return forEachSelection( 0, consumer ); - } - - default List getJdbcMappings() { - final List results = new ArrayList<>(); - forEachSelection( (index, selection) -> results.add( selection.getJdbcMapping() ) ); - return results; - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractDomainPath.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractDomainPath.java index 758776c0e6..5df863361d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractDomainPath.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractDomainPath.java @@ -12,7 +12,7 @@ import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.ordering.ast.DomainPath; import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlExpressionResolver; @@ -111,7 +111,7 @@ public abstract class AbstractDomainPath implements DomainPath { SqlAstCreationState creationState) { if ( embeddableValuedModelPart.getFetchableName() .equals( modelPartName ) || ELEMENT_TOKEN.equals( modelPartName ) ) { - embeddableValuedModelPart.forEachSelection( + embeddableValuedModelPart.forEachSelectable( (columnIndex, selection) -> { addSortSpecification( selection, @@ -139,7 +139,7 @@ public abstract class AbstractDomainPath implements DomainPath { } private void addSortSpecification( - SelectionMapping selection, + SelectableMapping selection, QuerySpec ast, TableGroup tableGroup, String collation, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java index fa005f5d37..9fab1dd338 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AnyKeyPart.java @@ -16,7 +16,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -197,7 +197,7 @@ public class AnyKeyPart implements BasicValuedModelPart, FetchOptions { } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { consumer.accept( offset, this ); return getJdbcTypeCount(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java index f91bc191f1..eca60cebcc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicEntityIdentifierMappingImpl.java @@ -17,7 +17,7 @@ import org.hibernate.mapping.IndexedConsumer; import org.hibernate.mapping.PersistentClass; import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping; import org.hibernate.metamodel.mapping.BasicValuedMapping; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -128,7 +128,7 @@ public class BasicEntityIdentifierMappingImpl implements BasicEntityIdentifierMa } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { consumer.accept( offset, this ); return getJdbcTypeCount(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java index 5c91dcdbbc..cf3e341c31 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java @@ -17,8 +17,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.mapping.CollectionPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.ConvertibleModelPart; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -55,18 +55,18 @@ public class BasicValuedCollectionPart private final Nature nature; private final BasicValueConverter valueConverter; - private final SelectionMapping selectionMapping; + private final SelectableMapping selectableMapping; public BasicValuedCollectionPart( CollectionPersister collectionDescriptor, Nature nature, BasicValueConverter valueConverter, - SelectionMapping selectionMapping) { + SelectableMapping selectableMapping) { this.navigableRole = collectionDescriptor.getNavigableRole().append( nature.getName() ); this.collectionDescriptor = collectionDescriptor; this.nature = nature; this.valueConverter = valueConverter; - this.selectionMapping = selectionMapping; + this.selectableMapping = selectableMapping; } @Override @@ -76,32 +76,32 @@ public class BasicValuedCollectionPart @Override public MappingType getPartMappingType() { - return selectionMapping.getJdbcMapping()::getJavaTypeDescriptor; + return selectableMapping.getJdbcMapping()::getJavaTypeDescriptor; } @Override public String getContainingTableExpression() { - return selectionMapping.getContainingTableExpression(); + return selectableMapping.getContainingTableExpression(); } @Override public String getSelectionExpression() { - return selectionMapping.getSelectionExpression(); + return selectableMapping.getSelectionExpression(); } @Override public boolean isFormula() { - return selectionMapping.isFormula(); + return selectableMapping.isFormula(); } @Override public String getCustomReadExpression() { - return selectionMapping.getCustomReadExpression(); + return selectableMapping.getCustomReadExpression(); } @Override public String getCustomWriteExpression() { - return selectionMapping.getCustomWriteExpression(); + return selectableMapping.getCustomWriteExpression(); } @Override @@ -111,7 +111,7 @@ public class BasicValuedCollectionPart @Override public JavaTypeDescriptor getJavaTypeDescriptor() { - return selectionMapping.getJdbcMapping().getJavaTypeDescriptor(); + return selectableMapping.getJdbcMapping().getJavaTypeDescriptor(); } @Override @@ -144,11 +144,11 @@ public class BasicValuedCollectionPart exprResolver.resolveSqlExpression( SqlExpressionResolver.createColumnReferenceKey( tableGroup.getPrimaryTableReference(), - selectionMapping.getSelectionExpression() + selectableMapping.getSelectionExpression() ), sqlAstProcessingState -> new ColumnReference( tableGroup.getPrimaryTableReference().getIdentificationVariable(), - selectionMapping, + selectableMapping, creationState.getSqlAstCreationState().getCreationContext().getSessionFactory() ) ), @@ -179,7 +179,7 @@ public class BasicValuedCollectionPart @Override public JdbcMapping getJdbcMapping() { - return selectionMapping.getJdbcMapping(); + return selectableMapping.getJdbcMapping(); } @Override @@ -251,13 +251,13 @@ public class BasicValuedCollectionPart @Override public int forEachJdbcType(int offset, IndexedConsumer action) { - action.accept( offset, selectionMapping.getJdbcMapping() ); + action.accept( offset, selectableMapping.getJdbcMapping() ); return getJdbcTypeCount(); } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { - consumer.accept( offset, selectionMapping ); + public int forEachSelectable(int offset, SelectableConsumer consumer) { + consumer.accept( offset, selectableMapping ); return getJdbcTypeCount(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java index 18fa0d84a4..cc55872fed 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java @@ -14,7 +14,7 @@ import org.hibernate.engine.FetchTiming; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.ConvertibleModelPart; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.ManagedMappingType; @@ -264,7 +264,7 @@ public class BasicValuedSingularAttributeMapping } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { consumer.accept( offset, this ); return getJdbcTypeCount(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java index 32d99351df..6f7bf176ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CompoundNaturalIdMapping.java @@ -24,14 +24,13 @@ import org.hibernate.loader.ast.internal.MultiNaturalIdLoaderStandard; import org.hibernate.loader.ast.spi.MultiNaturalIdLoader; import org.hibernate.loader.ast.spi.NaturalIdLoader; import org.hibernate.mapping.IndexedConsumer; -import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.NaturalIdMapping; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess; import org.hibernate.persister.entity.EntityPersister; @@ -341,10 +340,10 @@ public class CompoundNaturalIdMapping extends AbstractNaturalIdMapping implement } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { int span = 0; for ( int i = 0; i < attributes.size(); i++ ) { - span += attributes.get( i ).forEachSelection( span + offset, consumer ); + span += attributes.get( i ).forEachSelectable( span + offset, consumer ); } return span; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java index e3d9820b62..344d51c2e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java @@ -20,7 +20,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.property.access.internal.PropertyAccessStrategyBasicImpl; @@ -120,8 +120,8 @@ public class EmbeddedAttributeMapping } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { - return getEmbeddableTypeDescriptor().forEachSelection( offset, consumer ); + public int forEachSelectable(int offset, SelectableConsumer consumer) { + return getEmbeddableTypeDescriptor().forEachSelectable( offset, consumer ); } @Override @@ -202,7 +202,7 @@ public class EmbeddedAttributeMapping SqlAstCreationState sqlAstCreationState) { final List columnReferences = CollectionHelper.arrayList( embeddableMappingType.getJdbcTypeCount() ); final TableReference defaultTableReference = tableGroup.resolveTableReference( getContainingTableExpression() ); - getEmbeddableTypeDescriptor().forEachSelection( + getEmbeddableTypeDescriptor().forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = selection.getContainingTableExpression().equals( defaultTableReference.getTableExpression() ) ? defaultTableReference diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java index 507717950d..7750cea39e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java @@ -169,7 +169,7 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver(); final List expressions = new ArrayList<>(); - getEmbeddableTypeDescriptor().forEachSelection( + getEmbeddableTypeDescriptor().forEachSelectable( (columnIndex, selection) -> { assert containingTableExpression.equals( selection.getContainingTableExpression() ); expressions.add( diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedForeignKeyDescriptor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedForeignKeyDescriptor.java index 9110576da0..ebd6c879b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedForeignKeyDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedForeignKeyDescriptor.java @@ -20,8 +20,8 @@ import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMappings; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMappings; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.query.ComparisonOperator; import org.hibernate.query.NavigablePath; @@ -50,22 +50,22 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model private final EmbeddableValuedModelPart mappingType; private final String keyColumnContainingTable; - private final SelectionMappings keySelectionMappings; + private final SelectableMappings keySelectableMappings; private final String targetColumnContainingTable; - private final SelectionMappings targetSelectionMappings; + private final SelectableMappings targetSelectableMappings; private AssociationKey associationKey; public EmbeddedForeignKeyDescriptor( EmbeddableValuedModelPart mappingType, String keyColumnContainingTable, - SelectionMappings keySelectionMappings, + SelectableMappings keySelectableMappings, String targetColumnContainingTable, - SelectionMappings targetSelectionMappings, + SelectableMappings targetSelectableMappings, MappingModelCreationProcess creationProcess) { this.keyColumnContainingTable = keyColumnContainingTable; - this.keySelectionMappings = keySelectionMappings; + this.keySelectableMappings = keySelectableMappings; this.targetColumnContainingTable = targetColumnContainingTable; - this.targetSelectionMappings = targetSelectionMappings; + this.targetSelectableMappings = targetSelectableMappings; this.mappingType = mappingType; creationProcess.registerInitializationCallback( @@ -104,7 +104,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model collectionPath, tableGroup, targetColumnContainingTable, - targetSelectionMappings, + targetSelectableMappings, creationState ); } @@ -113,7 +113,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model collectionPath, tableGroup, keyColumnContainingTable, - keySelectionMappings, + keySelectableMappings, creationState ); } @@ -128,7 +128,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model collectionPath, tableGroup, keyColumnContainingTable, - keySelectionMappings, + keySelectableMappings, creationState ); } @@ -144,7 +144,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model collectionPath, tableGroup, keyColumnContainingTable, - keySelectionMappings, + keySelectableMappings, creationState ); } @@ -153,7 +153,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model collectionPath, tableGroup, targetColumnContainingTable, - targetSelectionMappings, + targetSelectableMappings, creationState ); } @@ -163,15 +163,15 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model NavigablePath collectionPath, TableGroup tableGroup, String columnContainingTable, - SelectionMappings selectionMappings, + SelectableMappings selectableMappings, DomainResultCreationState creationState) { final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState(); final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver(); final TableReference tableReference = tableGroup.resolveTableReference( columnContainingTable ); final String identificationVariable = tableReference.getIdentificationVariable(); - final List sqlSelections = new ArrayList<>( selectionMappings.getJdbcTypeCount() ); - selectionMappings.forEachSelection( + final List sqlSelections = new ArrayList<>( selectableMappings.getJdbcTypeCount() ); + selectableMappings.forEachSelectable( (columnIndex, selection) -> { final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection( sqlExpressionResolver.resolveSqlExpression( @@ -252,11 +252,11 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model final String lhsTableExpression = lhs.getTableExpression(); if ( lhsTableExpression.equals( keyColumnContainingTable ) ) { assert rhsTableExpression.equals( targetColumnContainingTable ); - return getPredicate( lhs, rhs, creationContext, keySelectionMappings, targetSelectionMappings ); + return getPredicate( lhs, rhs, creationContext, keySelectableMappings, targetSelectableMappings ); } else { assert rhsTableExpression.equals( keyColumnContainingTable ); - return getPredicate( lhs, rhs, creationContext, targetSelectionMappings, keySelectionMappings ); + return getPredicate( lhs, rhs, creationContext, targetSelectableMappings, keySelectableMappings ); } } @@ -264,10 +264,10 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model TableReference lhs, TableReference rhs, SqlAstCreationContext creationContext, - SelectionMappings lhsMappings, - SelectionMappings rhsMappings) { + SelectableMappings lhsMappings, + SelectableMappings rhsMappings) { final Junction predicate = new Junction( Junction.Nature.CONJUNCTION ); - lhsMappings.forEachSelection( + lhsMappings.forEachSelectable( (i, selection) -> { final ComparisonPredicate comparisonPredicate = new ComparisonPredicate( new ColumnReference( @@ -278,7 +278,7 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model ComparisonOperator.EQUAL, new ColumnReference( rhs, - rhsMappings.getSelectionMapping( i ), + rhsMappings.getSelectable( i ), creationContext.getSessionFactory() ) ); @@ -322,20 +322,20 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model } @Override - public int visitReferringColumns(int offset, SelectionConsumer consumer) { - return keySelectionMappings.forEachSelection( offset, consumer ); + public int visitReferringSelectables(int offset, SelectableConsumer consumer) { + return keySelectableMappings.forEachSelectable( offset, consumer ); } @Override - public int visitTargetColumns(int offset, SelectionConsumer consumer) { - return targetSelectionMappings.forEachSelection( offset, consumer ); + public int visitTargetSelectables(int offset, SelectableConsumer consumer) { + return targetSelectableMappings.forEachSelectable( offset, consumer ); } @Override public AssociationKey getAssociationKey() { if ( associationKey == null ) { final List columns = new ArrayList<>(); - keySelectionMappings.forEachSelection( + keySelectableMappings.forEachSelectable( (columnIndex, selection) -> { columns.add( selection.getSelectionExpression() ); } @@ -371,9 +371,9 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver(); final TableReference tableReference = tableGroup.resolveTableReference( keyColumnContainingTable ); final String identificationVariable = tableReference.getIdentificationVariable(); - final int size = keySelectionMappings.getJdbcTypeCount(); + final int size = keySelectableMappings.getJdbcTypeCount(); final List sqlSelections = new ArrayList<>( size ); - keySelectionMappings.forEachSelection( + keySelectableMappings.forEachSelectable( (columnIndex, selection) -> { final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection( sqlExpressionResolver.resolveSqlExpression( @@ -412,10 +412,8 @@ public class EmbeddedForeignKeyDescriptor implements ForeignKeyDescriptor, Model final Object[] values = (Object[]) domainValue; - keySelectionMappings.forEachSelection( - (selectionIndex, selectionMapping) -> { - valueConsumer.consume( values[ selectionIndex ], selectionMapping ); - } + keySelectableMappings.forEachSelectable( + (index, selectable) -> valueConsumer.consume( values[ index ], selectable ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java index 3b0e8428a1..48ea558844 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java @@ -21,16 +21,13 @@ import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.from.TableGroup; -import org.hibernate.sql.ast.tree.from.TableGroupJoin; -import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.Fetch; @@ -243,8 +240,8 @@ public class EntityCollectionPart // } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { - return entityMappingType.forEachSelection( offset, consumer ); + public int forEachSelectable(int offset, SelectableConsumer consumer) { + return entityMappingType.forEachSelectable( offset, consumer ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java index eedc55fa0e..39eb2d039c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityRowIdMappingImpl.java @@ -14,7 +14,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityRowIdMapping; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.spi.SqlAstCreationState; @@ -33,7 +33,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Nathan Xu */ -public class EntityRowIdMappingImpl implements EntityRowIdMapping, SelectionMapping { +public class EntityRowIdMappingImpl implements EntityRowIdMapping, SelectableMapping { private final String rowIdName; private final EntityMappingType declaringType; private final String tableExpression; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java index 8adc7ef6bc..6cb9655fe9 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityVersionMappingImpl.java @@ -12,8 +12,6 @@ import org.hibernate.LockMode; import org.hibernate.engine.FetchStyle; import org.hibernate.engine.FetchTiming; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.mapping.IndexedConsumer; -import org.hibernate.metamodel.mapping.SelectionConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityVersionMapping; import org.hibernate.metamodel.mapping.JdbcMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index b690d9d9d2..00804d0743 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -54,8 +54,8 @@ import org.hibernate.metamodel.mapping.CollectionIdentifierDescriptor; import org.hibernate.metamodel.mapping.CollectionMappingType; import org.hibernate.metamodel.mapping.CollectionPart; import org.hibernate.metamodel.mapping.PropertyBasedMapping; -import org.hibernate.metamodel.mapping.SelectionMapping; -import org.hibernate.metamodel.mapping.SelectionMappings; +import org.hibernate.metamodel.mapping.SelectableMapping; +import org.hibernate.metamodel.mapping.SelectableMappings; import org.hibernate.metamodel.mapping.CompositeIdentifierMapping; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; @@ -648,7 +648,7 @@ public class MappingModelCreationHelper { ); final BasicValue index = (BasicValue) ( (IndexedCollection) bootValueMapping ).getIndex(); - final SelectionMapping selectionMapping = SelectionMappingImpl.from( + final SelectableMapping selectableMapping = SelectableMappingImpl.from( tableExpression, index.getColumnIterator().next(), creationContext.getTypeConfiguration().getBasicTypeForJavaType( Integer.class ), @@ -660,7 +660,7 @@ public class MappingModelCreationHelper { CollectionPart.Nature.INDEX, // no converter null, - selectionMapping + selectableMapping ); break; @@ -699,7 +699,7 @@ public class MappingModelCreationHelper { } case LIST: { final BasicValue index = (BasicValue) ( (IndexedCollection) bootValueMapping ).getIndex(); - final SelectionMapping selectionMapping = SelectionMappingImpl.from( + final SelectableMapping selectableMapping = SelectableMappingImpl.from( tableExpression, index.getColumnIterator().next(), creationContext.getTypeConfiguration().getBasicTypeForJavaType( Integer.class ), @@ -711,7 +711,7 @@ public class MappingModelCreationHelper { CollectionPart.Nature.INDEX, // no converter null, - selectionMapping + selectableMapping ); collectionMappingType = new CollectionMappingTypeImpl( @@ -912,7 +912,7 @@ public class MappingModelCreationHelper { assert fkTarget instanceof BasicValuedModelPart; final BasicValuedModelPart simpleFkTarget = (BasicValuedModelPart) fkTarget; final String tableExpression = getTableIdentifierExpression( bootValueMappingKey.getTable(), creationProcess ); - final SelectionMapping keySelectionMapping = SelectionMappingImpl.from( + final SelectableMapping keySelectableMapping = SelectableMappingImpl.from( tableExpression, bootValueMappingKey.getColumnIterator().next(), (JdbcMapping) keyType, @@ -921,7 +921,7 @@ public class MappingModelCreationHelper { ); attributeMapping.setForeignKeyDescriptor( new SimpleForeignKeyDescriptor( - keySelectionMapping, + keySelectableMapping, simpleFkTarget, ( (PropertyBasedMapping) simpleFkTarget ).getPropertyAccess(), isReferenceToPrimaryKey @@ -1023,9 +1023,9 @@ public class MappingModelCreationHelper { final Iterator columnIterator = bootValueMapping.getColumnIterator(); final Table table = bootValueMapping.getTable(); final String tableExpression = getTableIdentifierExpression( table, creationProcess ); - final SelectionMapping keySelectionMapping; + final SelectableMapping keySelectableMapping; if ( columnIterator.hasNext() ) { - keySelectionMapping = SelectionMappingImpl.from( + keySelectableMapping = SelectableMappingImpl.from( tableExpression, columnIterator.next(), simpleFkTarget.getJdbcMapping(), @@ -1035,7 +1035,7 @@ public class MappingModelCreationHelper { } else { // case of ToOne with @PrimaryKeyJoinColumn - keySelectionMapping = SelectionMappingImpl.from( + keySelectableMapping = SelectableMappingImpl.from( tableExpression, table.getColumn( 0 ), simpleFkTarget.getJdbcMapping(), @@ -1045,7 +1045,7 @@ public class MappingModelCreationHelper { } final ForeignKeyDescriptor foreignKeyDescriptor = new SimpleForeignKeyDescriptor( - keySelectionMapping, + keySelectableMapping, simpleFkTarget, ( (PropertyBasedMapping) simpleFkTarget ).getPropertyAccess(), bootValueMapping.isReferenceToPrimaryKey() @@ -1089,7 +1089,7 @@ public class MappingModelCreationHelper { boolean inverse, Dialect dialect, MappingModelCreationProcess creationProcess) { - final SelectionMappings keySelectionMappings; + final SelectableMappings keySelectableMappings; final String keyTableExpression; if ( bootValueMapping instanceof Collection ) { final Collection collectionBootValueMapping = (Collection) bootValueMapping; @@ -1097,7 +1097,7 @@ public class MappingModelCreationHelper { collectionBootValueMapping.getCollectionTable(), creationProcess ); - keySelectionMappings = SelectionMappingsImpl.from( + keySelectableMappings = SelectableMappingsImpl.from( keyTableExpression, collectionBootValueMapping.getKey(), creationProcess.getCreationContext().getSessionFactory(), @@ -1110,7 +1110,7 @@ public class MappingModelCreationHelper { bootValueMapping.getTable(), creationProcess ); - keySelectionMappings = SelectionMappingsImpl.from( + keySelectableMappings = SelectableMappingsImpl.from( keyTableExpression, bootValueMapping, creationProcess.getCreationContext().getSessionFactory(), @@ -1124,7 +1124,7 @@ public class MappingModelCreationHelper { embeddableValuedModelPart.getContainingTableExpression(), embeddableValuedModelPart.getEmbeddableTypeDescriptor(), keyTableExpression, - keySelectionMappings, + keySelectableMappings, creationProcess ); } @@ -1132,7 +1132,7 @@ public class MappingModelCreationHelper { return new EmbeddedForeignKeyDescriptor( embeddableValuedModelPart, keyTableExpression, - keySelectionMappings, + keySelectableMappings, embeddableValuedModelPart.getContainingTableExpression(), embeddableValuedModelPart.getEmbeddableTypeDescriptor(), creationProcess @@ -1193,7 +1193,7 @@ public class MappingModelCreationHelper { if ( bootMapKeyDescriptor instanceof BasicValue ) { final BasicValue basicValue = (BasicValue) bootMapKeyDescriptor; - final SelectionMapping selectionMapping = SelectionMappingImpl.from( + final SelectableMapping selectableMapping = SelectableMappingImpl.from( tableExpression, basicValue.getColumnIterator().next(), basicValue.resolve().getJdbcMapping(), @@ -1204,7 +1204,7 @@ public class MappingModelCreationHelper { collectionDescriptor, CollectionPart.Nature.INDEX, basicValue.resolve().getValueConverter(), - selectionMapping + selectableMapping ); } @@ -1284,7 +1284,7 @@ public class MappingModelCreationHelper { if ( element instanceof BasicValue ) { final BasicValue basicElement = (BasicValue) element; - final SelectionMapping selectionMapping = SelectionMappingImpl.from( + final SelectableMapping selectableMapping = SelectableMappingImpl.from( tableExpression, basicElement.getColumnIterator().next(), basicElement.resolve().getJdbcMapping(), @@ -1295,7 +1295,7 @@ public class MappingModelCreationHelper { collectionDescriptor, CollectionPart.Nature.ELEMENT, basicElement.resolve().getValueConverter(), - selectionMapping + selectableMapping ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java index b39ee7d7f0..b9e8b13dea 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java @@ -40,7 +40,7 @@ import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PropertyBasedMapping; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess; import org.hibernate.metamodel.mapping.ordering.OrderByFragment; import org.hibernate.metamodel.mapping.ordering.OrderByFragmentTranslator; @@ -331,7 +331,7 @@ public class PluralAttributeMappingImpl if ( fkTargetPart instanceof BasicValuedModelPart ) { final BasicValuedModelPart basicFkTargetPart = (BasicValuedModelPart) fkTargetPart; final Joinable collectionDescriptorAsJoinable = (Joinable) collectionDescriptor; - final SelectionMapping keySelectionMapping = SelectionMappingImpl.from( + final SelectableMapping keySelectableMapping = SelectableMappingImpl.from( collectionDescriptorAsJoinable.getTableName(), fkBootDescriptorSource.getColumnIterator().next(), basicFkTargetPart.getJdbcMapping(), @@ -339,7 +339,7 @@ public class PluralAttributeMappingImpl creationProcess.getSqmFunctionRegistry() ); return new SimpleForeignKeyDescriptor( - keySelectionMapping, + keySelectableMapping, basicFkTargetPart, ( (PropertyBasedMapping) basicFkTargetPart ).getPropertyAccess(), entityType.isReferenceToPrimaryKey() diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingImpl.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingImpl.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingImpl.java index 93828a12c2..c562b60f88 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingImpl.java @@ -8,14 +8,14 @@ package org.hibernate.metamodel.mapping.internal; import org.hibernate.dialect.Dialect; import org.hibernate.mapping.Selectable; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.query.sqm.function.SqmFunctionRegistry; /** * @author Christian Beikov */ -public class SelectionMappingImpl implements SelectionMapping { +public class SelectableMappingImpl implements SelectableMapping { private final String containingTableExpression; private final String selectionExpression; @@ -24,7 +24,7 @@ public class SelectionMappingImpl implements SelectionMapping { private final boolean isFormula; private final JdbcMapping jdbcMapping; - public SelectionMappingImpl( + public SelectableMappingImpl( String containingTableExpression, String selectionExpression, String customReadExpression, @@ -40,7 +40,7 @@ public class SelectionMappingImpl implements SelectionMapping { this.jdbcMapping = jdbcMapping; } - public static SelectionMapping from( + public static SelectableMapping from( final String containingTableExpression, final Selectable selectable, final JdbcMapping jdbcMapping, @@ -53,7 +53,7 @@ public class SelectionMappingImpl implements SelectionMapping { else { columnExpression = selectable.getText( dialect ); } - return new SelectionMappingImpl( + return new SelectableMappingImpl( containingTableExpression, columnExpression, selectable.getCustomReadExpression(), diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingsImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingsImpl.java similarity index 61% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingsImpl.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingsImpl.java index fe3f6ae9cb..2e4f20b4f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectionMappingsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SelectableMappingsImpl.java @@ -17,9 +17,9 @@ import org.hibernate.mapping.Selectable; import org.hibernate.mapping.Value; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMapping; -import org.hibernate.metamodel.mapping.SelectionMappings; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMapping; +import org.hibernate.metamodel.mapping.SelectableMappings; import org.hibernate.query.sqm.function.SqmFunctionRegistry; import org.hibernate.type.CompositeType; import org.hibernate.type.EntityType; @@ -28,12 +28,12 @@ import org.hibernate.type.Type; /** * @author Christian Beikov */ -public class SelectionMappingsImpl implements SelectionMappings { +public class SelectableMappingsImpl implements SelectableMappings { - private final SelectionMapping[] selectionMappings; + private final SelectableMapping[] selectableMappings; - public SelectionMappingsImpl(SelectionMapping[] selectionMappings) { - this.selectionMappings = selectionMappings; + public SelectableMappingsImpl(SelectableMapping[] selectableMappings) { + this.selectableMappings = selectableMappings; } private static void resolveJdbcMappings(List jdbcMappings, Mapping mapping, Type valueType) { @@ -55,7 +55,7 @@ public class SelectionMappingsImpl implements SelectionMappings { } } - public static SelectionMappings from( + public static SelectableMappings from( String containingTableExpression, Value value, Mapping mapping, @@ -63,56 +63,56 @@ public class SelectionMappingsImpl implements SelectionMappings { SqmFunctionRegistry sqmFunctionRegistry) { final List jdbcMappings = new ArrayList<>(); resolveJdbcMappings( jdbcMappings, mapping, value.getType() ); - final List selectionMappings = new ArrayList<>( jdbcMappings.size() ); + final List selectableMappings = new ArrayList<>( jdbcMappings.size() ); final Iterator columnIterator = value.getColumnIterator(); while ( columnIterator.hasNext() ) { final Selectable selectable = columnIterator.next(); - selectionMappings.add( - SelectionMappingImpl.from( + selectableMappings.add( + SelectableMappingImpl.from( containingTableExpression, selectable, - jdbcMappings.get( selectionMappings.size() ), + jdbcMappings.get( selectableMappings.size() ), dialect, sqmFunctionRegistry ) ); } - return new SelectionMappingsImpl( selectionMappings.toArray( new SelectionMapping[0] ) ); + return new SelectableMappingsImpl( selectableMappings.toArray( new SelectableMapping[0] ) ); } - public static SelectionMappings from(EmbeddableMappingType embeddableMappingType) { + public static SelectableMappings from(EmbeddableMappingType embeddableMappingType) { final int propertySpan = embeddableMappingType.getNumberOfAttributeMappings(); - final List selectionMappings = CollectionHelper.arrayList( propertySpan ); + final List selectableMappings = CollectionHelper.arrayList( propertySpan ); embeddableMappingType.forEachAttributeMapping( (index, attributeMapping) -> { - attributeMapping.forEachSelection( + attributeMapping.forEachSelectable( (columnIndex, selection) -> { - selectionMappings.add( selection ); + selectableMappings.add( selection ); } ); } ); - return new SelectionMappingsImpl( selectionMappings.toArray( new SelectionMapping[0] ) ); + return new SelectableMappingsImpl( selectableMappings.toArray( new SelectableMapping[0] ) ); } @Override - public SelectionMapping getSelectionMapping(int columnIndex) { - return selectionMappings[columnIndex]; + public SelectableMapping getSelectable(int columnIndex) { + return selectableMappings[columnIndex]; } @Override public int getJdbcTypeCount() { - return selectionMappings.length; + return selectableMappings.length; } @Override - public int forEachSelection(final int offset, final SelectionConsumer consumer) { - for ( int i = 0; i < selectionMappings.length; i++ ) { - consumer.accept( offset + i, selectionMappings[i] ); + public int forEachSelectable(final int offset, final SelectableConsumer consumer) { + for ( int i = 0; i < selectableMappings.length; i++ ) { + consumer.accept( offset + i, selectableMappings[i] ); } - return selectionMappings.length; + return selectableMappings.length; } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java index 316c764175..3b37893c6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java @@ -16,8 +16,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.mapping.AssociationKey; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -51,31 +51,31 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; * @author Steve Ebersole */ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicValuedModelPart, FetchOptions { - private final SelectionMapping keySelectionMapping; - private final SelectionMapping targetSelectionMapping; + private final SelectableMapping keySelectableMapping; + private final SelectableMapping targetSelectableMapping; private final PropertyAccess propertyAccess; private final boolean refersToPrimaryKey; private AssociationKey associationKey; public SimpleForeignKeyDescriptor( - SelectionMapping keySelectionMapping, - SelectionMapping targetSelectionMapping, + SelectableMapping keySelectableMapping, + SelectableMapping targetSelectableMapping, PropertyAccess propertyAccess, boolean refersToPrimaryKey) { - this.keySelectionMapping = keySelectionMapping; - this.targetSelectionMapping = targetSelectionMapping; + this.keySelectableMapping = keySelectableMapping; + this.targetSelectableMapping = targetSelectableMapping; this.propertyAccess = propertyAccess; this.refersToPrimaryKey = refersToPrimaryKey; } @Override public String getKeyColumnContainingTable() { - return keySelectionMapping.getContainingTableExpression(); + return keySelectableMapping.getContainingTableExpression(); } @Override public String getTargetColumnContainingTable() { - return targetSelectionMapping.getContainingTableExpression(); + return targetSelectableMapping.getContainingTableExpression(); } @Override @@ -83,9 +83,9 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa NavigablePath collectionPath, TableGroup tableGroup, DomainResultCreationState creationState) { - if ( targetSelectionMapping.getContainingTableExpression() - .equals( keySelectionMapping.getContainingTableExpression() ) ) { - return createDomainResult( tableGroup, targetSelectionMapping, creationState ); + if ( targetSelectableMapping.getContainingTableExpression() + .equals( keySelectableMapping.getContainingTableExpression() ) ) { + return createDomainResult( tableGroup, targetSelectableMapping, creationState ); } return createDomainResult( collectionPath, tableGroup, creationState ); } @@ -95,7 +95,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa NavigablePath navigablePath, TableGroup tableGroup, DomainResultCreationState creationState) { - return createDomainResult( tableGroup, keySelectionMapping, creationState ); + return createDomainResult( tableGroup, keySelectableMapping, creationState ); } @Override @@ -105,9 +105,9 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa boolean isKeyReferringSide, DomainResultCreationState creationState) { if ( isKeyReferringSide ) { - return createDomainResult( tableGroup, keySelectionMapping, creationState ); + return createDomainResult( tableGroup, keySelectableMapping, creationState ); } - return createDomainResult( tableGroup, targetSelectionMapping, creationState ); + return createDomainResult( tableGroup, targetSelectableMapping, creationState ); } @Override @@ -116,31 +116,31 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa TableGroup tableGroup, String resultVariable, DomainResultCreationState creationState) { - return createDomainResult( tableGroup, keySelectionMapping, creationState ); + return createDomainResult( tableGroup, keySelectableMapping, creationState ); } private DomainResult createDomainResult( TableGroup tableGroup, - SelectionMapping selectionMapping, + SelectableMapping selectableMapping, DomainResultCreationState creationState) { final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState(); final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver(); - final TableReference tableReference = tableGroup.resolveTableReference( selectionMapping.getContainingTableExpression() ); + final TableReference tableReference = tableGroup.resolveTableReference( selectableMapping.getContainingTableExpression() ); final String identificationVariable = tableReference.getIdentificationVariable(); final SqlSelection sqlSelection = sqlExpressionResolver.resolveSqlSelection( sqlExpressionResolver.resolveSqlExpression( SqlExpressionResolver.createColumnReferenceKey( tableReference, - selectionMapping.getSelectionExpression() + selectableMapping.getSelectionExpression() ), s -> new ColumnReference( identificationVariable, - selectionMapping, + selectableMapping, creationState.getSqlAstCreationState().getCreationContext().getSessionFactory() ) ), - selectionMapping.getJdbcMapping().getJavaTypeDescriptor(), + selectableMapping.getJdbcMapping().getJavaTypeDescriptor(), sqlAstCreationState.getCreationContext().getDomainModel().getTypeConfiguration() ); @@ -148,7 +148,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa return new BasicResult( sqlSelection.getValuesArrayPosition(), null, - selectionMapping.getJdbcMapping().getJavaTypeDescriptor() + selectableMapping.getJdbcMapping().getJavaTypeDescriptor() ); } @@ -159,17 +159,17 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa SqlAstJoinType sqlAstJoinType, SqlExpressionResolver sqlExpressionResolver, SqlAstCreationContext creationContext) { - if ( lhs.getTableReference( keySelectionMapping.getContainingTableExpression() ) != null ) { + if ( lhs.getTableReference( keySelectableMapping.getContainingTableExpression() ) != null ) { return new ComparisonPredicate( new ColumnReference( lhs, - keySelectionMapping, + keySelectableMapping, creationContext.getSessionFactory() ), ComparisonOperator.EQUAL, new ColumnReference( rhs, - targetSelectionMapping, + targetSelectableMapping, creationContext.getSessionFactory() ) ); @@ -178,13 +178,13 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa return new ComparisonPredicate( new ColumnReference( lhs, - targetSelectionMapping, + targetSelectableMapping, creationContext.getSessionFactory() ), ComparisonOperator.EQUAL, new ColumnReference( rhs, - keySelectionMapping, + keySelectableMapping, creationContext.getSessionFactory() ) ); @@ -200,22 +200,22 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa SqlAstCreationContext creationContext) { TableReference lhsTableReference; TableReference rhsTableKeyReference; - if ( targetSelectionMapping.getContainingTableExpression().equals( keySelectionMapping.getContainingTableExpression() ) ) { - lhsTableReference = getTableReferenceWhenTargetEqualsKey( lhs, tableGroup, keySelectionMapping.getContainingTableExpression() ); + if ( targetSelectableMapping.getContainingTableExpression().equals( keySelectableMapping.getContainingTableExpression() ) ) { + lhsTableReference = getTableReferenceWhenTargetEqualsKey( lhs, tableGroup, keySelectableMapping.getContainingTableExpression() ); rhsTableKeyReference = getTableReference( lhs, tableGroup, - targetSelectionMapping.getContainingTableExpression() + targetSelectableMapping.getContainingTableExpression() ); } else { - lhsTableReference = getTableReference( lhs, tableGroup, keySelectionMapping.getContainingTableExpression() ); + lhsTableReference = getTableReference( lhs, tableGroup, keySelectableMapping.getContainingTableExpression() ); rhsTableKeyReference = getTableReference( lhs, tableGroup, - targetSelectionMapping.getContainingTableExpression() + targetSelectableMapping.getContainingTableExpression() ); } @@ -263,7 +263,7 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa @Override public JavaTypeDescriptor getJavaTypeDescriptor() { - return targetSelectionMapping.getJdbcMapping().getJavaTypeDescriptor(); + return targetSelectableMapping.getJdbcMapping().getJavaTypeDescriptor(); } @Override @@ -305,38 +305,38 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa @Override public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) { - valueConsumer.consume( domainValue, keySelectionMapping ); + valueConsumer.consume( domainValue, keySelectableMapping ); } @Override - public int visitReferringColumns(int offset, SelectionConsumer consumer) { - consumer.accept( offset, keySelectionMapping ); + public int visitReferringSelectables(int offset, SelectableConsumer consumer) { + consumer.accept( offset, keySelectableMapping ); return getJdbcTypeCount(); } @Override - public int visitTargetColumns(int offset, SelectionConsumer consumer) { - consumer.accept( offset, targetSelectionMapping ); + public int visitTargetSelectables(int offset, SelectableConsumer consumer) { + consumer.accept( offset, targetSelectableMapping ); return getJdbcTypeCount(); } @Override public AssociationKey getAssociationKey() { if ( associationKey == null ) { - final List associationKeyColumns = Collections.singletonList( keySelectionMapping.getSelectionExpression() ); - associationKey = new AssociationKey( keySelectionMapping.getContainingTableExpression(), associationKeyColumns ); + final List associationKeyColumns = Collections.singletonList( keySelectableMapping.getSelectionExpression() ); + associationKey = new AssociationKey( keySelectableMapping.getContainingTableExpression(), associationKeyColumns ); } return associationKey; } @Override public List getJdbcMappings() { - return Collections.singletonList( targetSelectionMapping.getJdbcMapping() ); + return Collections.singletonList( targetSelectableMapping.getJdbcMapping() ); } @Override public int forEachJdbcType(int offset, IndexedConsumer action) { - action.accept( offset, targetSelectionMapping.getJdbcMapping() ); + action.accept( offset, targetSelectableMapping.getJdbcMapping() ); return getJdbcTypeCount(); } @@ -347,34 +347,34 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa int offset, JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session) { - valuesConsumer.consume( offset, value, targetSelectionMapping.getJdbcMapping() ); + valuesConsumer.consume( offset, value, targetSelectableMapping.getJdbcMapping() ); return getJdbcTypeCount(); } @Override public String getContainingTableExpression() { - return keySelectionMapping.getContainingTableExpression(); + return keySelectableMapping.getContainingTableExpression(); } @Override public String getSelectionExpression() { - return keySelectionMapping.getSelectionExpression(); + return keySelectableMapping.getSelectionExpression(); } @Override public boolean isFormula() { - return keySelectionMapping.isFormula(); + return keySelectableMapping.isFormula(); } @Override public String getCustomReadExpression() { - return keySelectionMapping.getCustomReadExpression(); + return keySelectableMapping.getCustomReadExpression(); } @Override public String getCustomWriteExpression() { - return keySelectionMapping.getCustomWriteExpression(); + return keySelectableMapping.getCustomWriteExpression(); } @Override @@ -416,13 +416,13 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa @Override public JdbcMapping getJdbcMapping() { - return keySelectionMapping.getJdbcMapping(); + return keySelectableMapping.getJdbcMapping(); } @Override public String toString() { - return "SimpleForeignKeyDescriptor : " + keySelectionMapping.getContainingTableExpression() + "." + keySelectionMapping + return "SimpleForeignKeyDescriptor : " + keySelectableMapping.getContainingTableExpression() + "." + keySelectableMapping .getSelectionExpression() - + " --> " + targetSelectionMapping.getContainingTableExpression() + "." + targetSelectionMapping.getSelectionExpression(); + + " --> " + targetSelectableMapping.getContainingTableExpression() + "." + targetSelectableMapping.getSelectionExpression(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java index 8e6dbb64e0..9064068a82 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleNaturalIdMapping.java @@ -22,7 +22,7 @@ import org.hibernate.mapping.IndexedConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingType; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NavigablePath; @@ -189,8 +189,8 @@ public class SimpleNaturalIdMapping extends AbstractNaturalIdMapping { } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { - return attribute.forEachSelection( offset, consumer ); + public int forEachSelectable(int offset, SelectableConsumer consumer) { + return attribute.forEachSelectable( offset, consumer ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectionMappings.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectableMappings.java similarity index 77% rename from hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectionMappings.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectableMappings.java index c618660ee7..25e32b8ca5 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectionMappings.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingleSelectableMappings.java @@ -9,14 +9,14 @@ package org.hibernate.metamodel.mapping.internal; import java.util.List; import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.metamodel.mapping.SelectionConsumer; -import org.hibernate.metamodel.mapping.SelectionMapping; -import org.hibernate.metamodel.mapping.SelectionMappings; +import org.hibernate.metamodel.mapping.SelectableConsumer; +import org.hibernate.metamodel.mapping.SelectableMapping; +import org.hibernate.metamodel.mapping.SelectableMappings; /** * @author Steve Ebersole */ -public class SingleSelectionMappings implements SelectionMapping, SelectionMappings { +public class SingleSelectableMappings implements SelectableMapping, SelectableMappings { private final String tableName; private final String expression; private final String readExpression; @@ -24,7 +24,7 @@ public class SingleSelectionMappings implements SelectionMapping, SelectionMappi private final boolean isFormula; private final JdbcMapping jdbcMapping; - public SingleSelectionMappings( + public SingleSelectableMappings( String tableName, String expression, String readExpression, @@ -70,7 +70,7 @@ public class SingleSelectionMappings implements SelectionMapping, SelectionMappi } @Override - public SelectionMapping getSelectionMapping(int columnIndex) { + public SelectableMapping getSelectable(int columnIndex) { return this; } @@ -80,16 +80,15 @@ public class SingleSelectionMappings implements SelectionMapping, SelectionMappi } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { assert offset == 1; consumer.accept( offset, this ); return 1; } @Override - public int forEachSelection(SelectionConsumer consumer) { + public void forEachSelectable(SelectableConsumer consumer) { consumer.accept( 0, this ); - return 1; } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java index 4b4cf1dee1..c8a13a22d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java @@ -24,7 +24,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.PluralAttributeMapping; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.StateArrayContributorMetadataAccess; import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.persister.entity.EntityPersister; @@ -667,9 +667,9 @@ public class ToOneAttributeMapping } @Override - public int forEachSelection(int offset, SelectionConsumer consumer) { + public int forEachSelectable(int offset, SelectableConsumer consumer) { if ( isKeyReferringSide ) { - return foreignKeyDescriptor.visitReferringColumns( offset, consumer ); + return foreignKeyDescriptor.visitReferringSelectables( offset, consumer ); } else { return 0; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 98ff548616..f501190dcd 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -157,7 +157,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.NaturalIdMapping; import org.hibernate.metamodel.mapping.Queryable; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.StateArrayContributorMapping; import org.hibernate.metamodel.mapping.StateArrayContributorMetadata; @@ -1502,7 +1502,7 @@ public abstract class AbstractEntityPersister assert rootPkColumnNames.length == fkColumnNames.length; assert rootPkColumnNames.length == identifierMapping.getJdbcTypeCount(); - identifierMapping.forEachSelection( + identifierMapping.forEachSelectable( (columnIndex, selection) -> { final String rootPkColumnName = rootPkColumnNames[ columnIndex ]; final Expression pkColumnExpression = sqlExpressionResolver.resolveSqlExpression( @@ -6839,11 +6839,11 @@ public abstract class AbstractEntityPersister } @Override - public int forEachSelection(int offset, SelectionConsumer selectionConsumer) { + public int forEachSelectable(int offset, SelectableConsumer selectableConsumer) { int span = 0; final List mappings = getAttributeMappings(); for ( int i = 0; i < mappings.size(); i++ ) { - span += mappings.get( i ).forEachSelection( span + offset, selectionConsumer ); + span += mappings.get( i ).forEachSelectable( span + offset, selectableConsumer ); } return span; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java index 7570fa87f9..604d6cf8e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java @@ -85,7 +85,7 @@ public class MatchingIdSelectionHelper { //noinspection rawtypes final List domainResults = new ArrayList<>(); - targetEntityDescriptor.getIdentifierMapping().forEachSelection( + targetEntityDescriptor.getIdentifierMapping().forEachSelectable( (position, selection) -> { final TableReference tableReference = mutatingTableGroup.resolveTableReference( selection.getContainingTableExpression() ); final Expression expression = sqmConverter.getSqlExpressionResolver().resolveSqlExpression( @@ -151,7 +151,7 @@ public class MatchingIdSelectionHelper { final TableGroup mutatingTableGroup = sqmConverter.getMutatingTableGroup(); idSelectionQuery.getFromClause().addRoot( mutatingTableGroup ); - targetEntityDescriptor.getIdentifierMapping().forEachSelection( + targetEntityDescriptor.getIdentifierMapping().forEachSelectable( (position, selection) -> { final TableReference tableReference = mutatingTableGroup.resolveTableReference( selection.getContainingTableExpression() ); final Expression expression = sqmConverter.getSqlExpressionResolver().resolveSqlExpression( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteDeleteHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteDeleteHandler.java index f1632a3f2f..eb37fec0a0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteDeleteHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteDeleteHandler.java @@ -18,8 +18,6 @@ import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter; import org.hibernate.query.sqm.tree.cte.SqmCteTable; import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.ast.spi.SqlAliasBase; -import org.hibernate.sql.ast.spi.SqlAliasBaseManager; import org.hibernate.sql.ast.tree.MutationStatement; import org.hibernate.sql.ast.tree.cte.CteContainer; import org.hibernate.sql.ast.tree.cte.CteStatement; @@ -28,7 +26,6 @@ import org.hibernate.sql.ast.tree.delete.DeleteStatement; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.from.TableGroup; -import org.hibernate.sql.ast.tree.from.TableGroupProducer; import org.hibernate.sql.ast.tree.from.TableReference; /** @@ -77,16 +74,14 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele ); final TableReference dmlTableReference = new TableReference( tableExpression, null, true, factory ); final List columnReferences = new ArrayList<>( idSelectCte.getCteTable().getCteColumns().size() ); - pluralAttribute.getKeyDescriptor().visitReferringColumns( - (selectionIndex, selectionMapping) -> { - columnReferences.add( - new ColumnReference( - dmlTableReference, - selectionMapping, - factory - ) - ); - } + pluralAttribute.getKeyDescriptor().visitReferringSelectables( + (index, selectable) -> columnReferences.add( + new ColumnReference( + dmlTableReference, + selectable, + factory + ) + ) ); final MutationStatement dmlStatement = new DeleteStatement( dmlTableReference, @@ -109,15 +104,13 @@ public class CteDeleteHandler extends AbstractCteMutationHandler implements Dele final TableReference dmlTableReference = updatingTableGroup.resolveTableReference( tableExpression ); final List columnReferences = new ArrayList<>( idSelectCte.getCteTable().getCteColumns().size() ); tableColumnsVisitationSupplier.get().accept( - (selectionIndex, selectionMapping) -> { - columnReferences.add( - new ColumnReference( - dmlTableReference, - selectionMapping, - factory - ) - ); - } + (index, selectable) -> columnReferences.add( + new ColumnReference( + dmlTableReference, + selectable, + factory + ) + ) ); final MutationStatement dmlStatement = new DeleteStatement( dmlTableReference, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java index 6fb0944a21..8082044f2d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteUpdateHandler.java @@ -140,15 +140,13 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda final TableReference dmlTableReference = updatingTableGroup.resolveTableReference( tableExpression ); final List columnReferences = new ArrayList<>( idSelectCte.getCteTable().getCteColumns().size() ); tableColumnsVisitationSupplier.get().accept( - (selectionIndex, selectionMapping) -> { - columnReferences.add( - new ColumnReference( - dmlTableReference, - selectionMapping, - factory - ) - ); - } + (index, selectable) -> columnReferences.add( + new ColumnReference( + dmlTableReference, + selectable, + factory + ) + ) ); final MutationStatement dmlStatement = new UpdateStatement( dmlTableReference, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java index 41a3f64469..ce0c8b7d20 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java @@ -85,7 +85,7 @@ public final class ExecuteWithIdTableHelper { matchingIdSelection.getFromClause().addRoot( mutatingTableGroup ); - mutatingEntityDescriptor.getIdentifierMapping().forEachSelection( + mutatingEntityDescriptor.getIdentifierMapping().forEachSelectable( (jdbcPosition, selection) -> { final TableReference tableReference = mutatingTableGroup.resolveTableReference( selection.getContainingTableExpression() ); matchingIdSelection.getSelectClause().addSqlSelection( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithoutIdTableHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithoutIdTableHelper.java index 1e40f7a4dd..2f2f818076 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithoutIdTableHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithoutIdTableHelper.java @@ -49,7 +49,7 @@ public final class ExecuteWithoutIdTableHelper { matchingIdSelect.getFromClause().addRoot( matchingIdSelectTableGroup ); - rootEntityPersister.getIdentifierMapping().forEachSelection( + rootEntityPersister.getIdentifierMapping().forEachSelectable( (columnIndex, selection) -> { final ColumnReference columnReference = (ColumnReference) sqlExpressionResolver.resolveSqlExpression( SqlExpressionResolver.createColumnReferenceKey( rootTableReference, selection.getSelectionExpression() ), diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/IdTable.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/IdTable.java index dd2a1ea639..8f0a9e67ec 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/IdTable.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/IdTable.java @@ -38,7 +38,7 @@ public class IdTable implements Exportable, Contributable { ( (Joinable) entityDescriptor.getEntityPersister() ).getTableName() ); - entityDescriptor.getIdentifierMapping().forEachSelection( + entityDescriptor.getIdentifierMapping().forEachSelectable( (columnIndex, selection) -> columns.add( new IdTableColumn( this, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java index 6d572caf0d..76774f48e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java @@ -23,7 +23,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.MutableInteger; import org.hibernate.internal.FilterHelper; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.MappingModelHelper; @@ -267,7 +267,7 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle private void deleteFromNonRootTableWithoutIdTable( TableReference targetTableReference, - Supplier> tableKeyColumnVisitationSupplier, + Supplier> tableKeyColumnVisitationSupplier, SqlExpressionResolver sqlExpressionResolver, TableGroup rootTableGroup, QuerySpec matchingIdSubQuerySpec, @@ -448,7 +448,7 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle private void deleteFromTableUsingIdTable( String tableExpression, - Supplier> tableKeyColumnVisitationSupplier, + Supplier> tableKeyColumnVisitationSupplier, QuerySpec idTableSubQuery, ExecutionContext executionContext) { log.tracef( "deleteFromTableUsingIdTable - %s", tableExpression ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java index 19cb3002a0..b07a46b720 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java @@ -18,7 +18,7 @@ import org.hibernate.engine.jdbc.spi.JdbcServices; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.query.spi.SqlOmittingQueryOptions; @@ -216,7 +216,7 @@ public class UpdateExecutionDelegate implements TableBasedUpdateHandler.Executio private void updateTable( String tableExpression, - Supplier> tableKeyColumnVisitationSupplier, + Supplier> tableKeyColumnVisitationSupplier, QuerySpec idTableSubQuery, ExecutionContext executionContext) { final TableReference updatingTableReference = updatingTableGroup.resolveTableReference( tableExpression ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/DisjunctionRestrictionProducer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/DisjunctionRestrictionProducer.java index a6f1a9c8ca..0ad6e4a792 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/DisjunctionRestrictionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/DisjunctionRestrictionProducer.java @@ -13,7 +13,7 @@ import java.util.function.Supplier; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -47,7 +47,7 @@ public class DisjunctionRestrictionProducer implements MatchingIdRestrictionProd List matchingIdValues, EntityMappingType entityDescriptor, TableReference mutatingTableReference, - Supplier> columnsToMatchVisitationSupplier, + Supplier> columnsToMatchVisitationSupplier, ExecutionContext executionContext) { assert matchingIdValues != null; assert ! matchingIdValues.isEmpty(); @@ -87,7 +87,7 @@ public class DisjunctionRestrictionProducer implements MatchingIdRestrictionProd else { final List columnReferences = new ArrayList<>( idColumnCount ); final List jdbcMappings = new ArrayList<>( idColumnCount ); - identifierMapping.forEachSelection( + identifierMapping.forEachSelectable( (columnIndex, selection) -> { columnReferences.add( new ColumnReference( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InPredicateRestrictionProducer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InPredicateRestrictionProducer.java index 418c53afba..e64ec699c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InPredicateRestrictionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InPredicateRestrictionProducer.java @@ -13,7 +13,7 @@ import java.util.function.Supplier; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.metamodel.mapping.BasicValuedModelPart; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityIdentifierMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; @@ -49,7 +49,7 @@ public class InPredicateRestrictionProducer implements MatchingIdRestrictionProd List matchingIdValues, EntityMappingType entityDescriptor, TableReference mutatingTableReference, - Supplier> columnsToMatchVisitationSupplier, + Supplier> columnsToMatchVisitationSupplier, ExecutionContext executionContext) { assert matchingIdValues != null; assert ! matchingIdValues.isEmpty(); @@ -84,7 +84,7 @@ public class InPredicateRestrictionProducer implements MatchingIdRestrictionProd else { final List columnReferences = new ArrayList<>( idColumnCount ); final List jdbcMappings = new ArrayList<>( idColumnCount ); - identifierMapping.forEachSelection( + identifierMapping.forEachSelectable( (columnIndex, selection) -> { columnReferences.add( new ColumnReference( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java index 869cd6c26e..714d7d5190 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/InlineDeleteHandler.java @@ -12,7 +12,7 @@ import java.util.function.Consumer; import java.util.function.Supplier; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.spi.SqlOmittingQueryOptions; @@ -137,7 +137,7 @@ public class InlineDeleteHandler implements DeleteHandler { private void executeDelete( String targetTableExpression, EntityMappingType entityDescriptor, - Supplier> tableKeyColumnsVisitationSupplier, + Supplier> tableKeyColumnsVisitationSupplier, List ids, JdbcParameterBindings jdbcParameterBindings, ExecutionContext executionContext) { diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/MatchingIdRestrictionProducer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/MatchingIdRestrictionProducer.java index 7e2a2885ba..506f1c20b6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/MatchingIdRestrictionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/MatchingIdRestrictionProducer.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.function.Consumer; import java.util.function.Supplier; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.predicate.Predicate; @@ -34,6 +34,6 @@ public interface MatchingIdRestrictionProducer { List matchingIdValues, EntityMappingType entityDescriptor, TableReference mutatingTableReference, - Supplier> columnsToMatchVisitationSupplier, + Supplier> columnsToMatchVisitationSupplier, ExecutionContext executionContext); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/TableValueConstructorRestrictionProducer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/TableValueConstructorRestrictionProducer.java index cb163aab36..2e5c79540e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/TableValueConstructorRestrictionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/inline/TableValueConstructorRestrictionProducer.java @@ -11,7 +11,7 @@ import java.util.function.Consumer; import java.util.function.Supplier; import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.metamodel.mapping.SelectionConsumer; +import org.hibernate.metamodel.mapping.SelectableConsumer; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate; @@ -48,7 +48,7 @@ public class TableValueConstructorRestrictionProducer implements MatchingIdRestr List matchingIdValues, EntityMappingType entityDescriptor, TableReference mutatingTableReference, - Supplier> columnsToMatchVisitationSupplier, + Supplier> columnsToMatchVisitationSupplier, ExecutionContext executionContext) { // Not "yet" implemented. Not sure we will. This requires the ability to define // "in-line views" with a table-ctor which the SQL AST does not yet define support for diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 1b1cabdcd3..dea22f93c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -35,7 +35,6 @@ import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.graph.spi.AppliedGraph; import org.hibernate.internal.FilterHelper; -import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.Stack; import org.hibernate.internal.util.collections.StandardStack; @@ -56,7 +55,6 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.PluralAttributeMapping; -import org.hibernate.metamodel.mapping.SelectionMapping; import org.hibernate.metamodel.mapping.internal.EmbeddedCollectionPart; import org.hibernate.metamodel.mapping.internal.EntityCollectionPart; import org.hibernate.metamodel.mapping.ordering.OrderByFragment; @@ -1598,43 +1596,41 @@ public abstract class BaseSqmToSqlAstConverter extends Base final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping(); final int jdbcTypeCount = identifierMapping.getJdbcTypeCount(); if ( jdbcTypeCount == 1 ) { - identifierMapping.forEachSelection( - (selectionIndex, selectionMapping) -> { - additionalRestrictions = SqlAstTreeHelper.combinePredicates( - additionalRestrictions, - new ComparisonPredicate( - new ColumnReference( - parentTableGroup.getTableReference( selectionMapping.getContainingTableExpression() ), - selectionMapping, - sessionFactory - ), - ComparisonOperator.EQUAL, - new ColumnReference( - tableGroup.getTableReference( selectionMapping.getContainingTableExpression() ), - selectionMapping, - sessionFactory - ) - ) - ); - } + identifierMapping.forEachSelectable( + (index, selectable) -> additionalRestrictions = SqlAstTreeHelper.combinePredicates( + additionalRestrictions, + new ComparisonPredicate( + new ColumnReference( + parentTableGroup.getTableReference( selectable.getContainingTableExpression() ), + selectable, + sessionFactory + ), + ComparisonOperator.EQUAL, + new ColumnReference( + tableGroup.getTableReference( selectable.getContainingTableExpression() ), + selectable, + sessionFactory + ) + ) + ) ); } else { final List lhs = new ArrayList<>( jdbcTypeCount ); final List rhs = new ArrayList<>( jdbcTypeCount ); - identifierMapping.forEachSelection( - (selectionIndex, selectionMapping) -> { + identifierMapping.forEachSelectable( + (index, selectable) -> { lhs.add( new ColumnReference( - parentTableGroup.getTableReference( selectionMapping.getContainingTableExpression() ), - selectionMapping, + parentTableGroup.getTableReference( selectable.getContainingTableExpression() ), + selectable, sessionFactory ) ); rhs.add( new ColumnReference( - tableGroup.getTableReference( selectionMapping.getContainingTableExpression() ), - selectionMapping, + tableGroup.getTableReference( selectable.getContainingTableExpression() ), + selectable, sessionFactory ) ); diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java index 6b9216ba41..e78b5773d0 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java @@ -90,7 +90,7 @@ public class EntityValuedPathInterpretation extends AbstractSqmPathInterpreta final ToOneAttributeMapping toOne = (ToOneAttributeMapping) mapping; final ModelPart modelPart = getModelPart( sqlAstCreationState, toOne ); - modelPart.forEachSelection( + modelPart.forEachSelectable( (columnIndex, selection) -> { final TableReference tableReference = getTableReference( sqmPath, @@ -147,18 +147,18 @@ public class EntityValuedPathInterpretation extends AbstractSqmPathInterpreta } ); - entityCollectionPart.forEachSelection( - (selectionIndex, selectionMapping) -> { - final TableReference tableReference = mapTableGroup.resolveTableReference( selectionMapping.getContainingTableExpression() ); + entityCollectionPart.forEachSelectable( + (index, selectable) -> { + final TableReference tableReference = mapTableGroup.resolveTableReference( selectable.getContainingTableExpression() ); final SqlExpressionResolver expressionResolver = sqlAstCreationState.getSqlExpressionResolver(); columnReferences.add( (ColumnReference) expressionResolver.resolveSqlExpression( - createColumnReferenceKey( tableReference, selectionMapping.getSelectionExpression() ), + createColumnReferenceKey( tableReference, selectable.getSelectionExpression() ), (processingState) -> new ColumnReference( tableReference.getIdentificationVariable(), - selectionMapping, + selectable, sqlAstCreationState.getCreationContext().getSessionFactory() ) ) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java index 2e4a101632..052decf875 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java @@ -39,7 +39,7 @@ public class CteTable { public CteTable(String cteName, EntityMappingType entityDescriptor) { final int numberOfColumns = entityDescriptor.getIdentifierMapping().getJdbcTypeCount(); final List columns = new ArrayList<>( numberOfColumns ); - entityDescriptor.getIdentifierMapping().forEachSelection( + entityDescriptor.getIdentifierMapping().forEachSelectable( (columnIndex, selection) -> columns.add( new CteColumn("cte_" + selection.getSelectionExpression(), selection.getJdbcMapping() ) ) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java index 154a39863a..990694da1d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java @@ -13,7 +13,7 @@ import java.util.function.Consumer; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.StringHelper; -import org.hibernate.metamodel.mapping.SelectionMapping; +import org.hibernate.metamodel.mapping.SelectableMapping; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.sql.Template; @@ -39,15 +39,15 @@ public class ColumnReference implements Expression, Assignable { public ColumnReference( String qualifier, - SelectionMapping selectionMapping, + SelectableMapping selectableMapping, SessionFactoryImplementor sessionFactory) { this( qualifier, - selectionMapping.getSelectionExpression(), - selectionMapping.isFormula(), - selectionMapping.getCustomReadExpression(), - selectionMapping.getCustomWriteExpression(), - selectionMapping.getJdbcMapping(), + selectableMapping.getSelectionExpression(), + selectableMapping.isFormula(), + selectableMapping.getCustomReadExpression(), + selectableMapping.getCustomWriteExpression(), + selectableMapping.getJdbcMapping(), sessionFactory ); } @@ -99,11 +99,11 @@ public class ColumnReference implements Expression, Assignable { public ColumnReference( TableReference tableReference, - SelectionMapping selectionMapping, + SelectableMapping selectableMapping, SessionFactoryImplementor sessionFactory) { this( tableReference.getIdentificationVariable(), - selectionMapping, + selectableMapping, sessionFactory ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/SmokeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/SmokeTests.java index 0571f10035..41a6b11171 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/SmokeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/SmokeTests.java @@ -134,11 +134,11 @@ public class SmokeTests { assertThat( attrMapping.getContainingTableExpression(), is( "mapping_simple_entity" ) ); assertThat( attrMapping.getEmbeddableTypeDescriptor().getJdbcTypeCount(), is( 4 ) ); assertThat( - attrMapping.getEmbeddableTypeDescriptor().getSelectionMapping( 0 ).getSelectionExpression(), + attrMapping.getEmbeddableTypeDescriptor().getSelectable( 0 ).getSelectionExpression(), is( "attribute1" ) ); assertThat( - attrMapping.getEmbeddableTypeDescriptor().getSelectionMapping( 1 ).getSelectionExpression(), + attrMapping.getEmbeddableTypeDescriptor().getSelectable( 1 ).getSelectionExpression(), is( "attribute2" ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneJoinTableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneJoinTableTest.java index a06d058007..81b918b066 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneJoinTableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneJoinTableTest.java @@ -56,14 +56,14 @@ public class ManyToOneJoinTableTest { final ToOneAttributeMapping simpleAttributeMapping = (ToOneAttributeMapping) simpleEntityAssociation; ForeignKeyDescriptor foreignKeyDescriptor = simpleAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_simple" ) ); assertThat( selection.getSelectionExpression(), is( "RHS_ID" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "simple_entity" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); @@ -77,14 +77,14 @@ public class ManyToOneJoinTableTest { final ToOneAttributeMapping anotherAttributeMapping = (ToOneAttributeMapping) anotherEntityAssociation; foreignKeyDescriptor = anotherAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_another" ) ); assertThat( selection.getSelectionExpression(), is( "RHS_ID" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "another_entity" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); @@ -103,14 +103,14 @@ public class ManyToOneJoinTableTest { ToOneAttributeMapping otherAttributeMapping = (ToOneAttributeMapping) otherEntityEntityAssociation; foreignKeyDescriptor = otherAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_simple" ) ); assertThat( selection.getSelectionExpression(), is( "LHS_ID" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_entity" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); @@ -129,14 +129,14 @@ public class ManyToOneJoinTableTest { otherAttributeMapping = (ToOneAttributeMapping) otherEntityEntityAssociation; foreignKeyDescriptor = otherAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "another_entity" ) ); assertThat( selection.getSelectionExpression(), is( "other_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_entity" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneTest.java index b202739bd8..68b4f21009 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/manytoone/ManyToOneTest.java @@ -53,14 +53,14 @@ public class ManyToOneTest { final ToOneAttributeMapping childAttributeMapping = (ToOneAttributeMapping) simpleEntityAssociation; ForeignKeyDescriptor foreignKeyDescriptor = childAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "other_entity" ) ); assertThat( selection.getSelectionExpression(), is( "simple_entity_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "simple_entity" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithBidirectionalAssociationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithBidirectionalAssociationTest.java index f6f90d632b..b5635442f6 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithBidirectionalAssociationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithBidirectionalAssociationTest.java @@ -51,14 +51,14 @@ public class EntityWithBidirectionalAssociationTest { final ToOneAttributeMapping childAttributeMapping = (ToOneAttributeMapping) childAssociation; ForeignKeyDescriptor foreignKeyDescriptor = childAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "PARENT" ) ); assertThat( selection.getSelectionExpression(), is( "child_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "CHILD" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); @@ -76,14 +76,14 @@ public class EntityWithBidirectionalAssociationTest { final ToOneAttributeMapping parentAttributeMapping = (ToOneAttributeMapping) parentAssociation; foreignKeyDescriptor = parentAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "PARENT" ) ); assertThat( selection.getSelectionExpression(), is( "child_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "CHILD" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneBidirectionalJoinTableAssociationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneBidirectionalJoinTableAssociationTest.java index 307609335b..e31616a03d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneBidirectionalJoinTableAssociationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneBidirectionalJoinTableAssociationTest.java @@ -53,14 +53,14 @@ public class EntityWithOneBidirectionalJoinTableAssociationTest { final ToOneAttributeMapping childAttributeMapping = (ToOneAttributeMapping) childAssociation; ForeignKeyDescriptor foreignKeyDescriptor = childAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "PARENT_CHILD" ) ); assertThat( selection.getSelectionExpression(), is( "child_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "CHILD" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); @@ -78,14 +78,14 @@ public class EntityWithOneBidirectionalJoinTableAssociationTest { final ToOneAttributeMapping parentAttributeMapping = (ToOneAttributeMapping) parentAssociation; foreignKeyDescriptor = parentAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "PARENT_CHILD" ) ); assertThat( selection.getSelectionExpression(), is( "parent_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "PARENT" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneJoinTableTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneJoinTableTest.java index bf86709c2f..96243c51e9 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneJoinTableTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneJoinTableTest.java @@ -47,14 +47,14 @@ public class EntityWithOneToOneJoinTableTest { final ToOneAttributeMapping otherAttributeMapping = (ToOneAttributeMapping) other; final ForeignKeyDescriptor foreignKeyDescriptor = otherAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "Entity_SimpleEntity" ) ); assertThat( selection.getSelectionExpression(), is( "other_id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "SIMPLE_ENTITY" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneSharingPrimaryKeyTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneSharingPrimaryKeyTest.java index 4404349c5a..ec2b236f38 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneSharingPrimaryKeyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/onetoone/EntityWithOneToOneSharingPrimaryKeyTest.java @@ -48,14 +48,14 @@ public class EntityWithOneToOneSharingPrimaryKeyTest { final ToOneAttributeMapping otherAttributeMapping = (ToOneAttributeMapping) otherAssociation; ForeignKeyDescriptor foreignKeyDescriptor = otherAttributeMapping.getForeignKeyDescriptor(); - foreignKeyDescriptor.visitReferringColumns( + foreignKeyDescriptor.visitReferringSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "EntityWithOneToOneSharingPrimaryKey" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); } ); - foreignKeyDescriptor.visitTargetColumns( + foreignKeyDescriptor.visitTargetSelectables( (columnIndex, selection) -> { assertThat( selection.getContainingTableExpression(), is( "SIMPLE_ENTITY" ) ); assertThat( selection.getSelectionExpression(), is( "id" ) ); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/readwrite/AbstractReadWriteTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/readwrite/AbstractReadWriteTests.java index 3f8610af01..c56d316044 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/readwrite/AbstractReadWriteTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/readwrite/AbstractReadWriteTests.java @@ -9,7 +9,6 @@ package org.hibernate.orm.test.mapping.readwrite; import org.hibernate.mapping.BasicValue; import org.hibernate.mapping.Column; import org.hibernate.mapping.Property; -import org.hibernate.metamodel.mapping.AttributeMapping; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.internal.BasicValuedSingularAttributeMapping; @@ -43,7 +42,7 @@ public abstract class AbstractReadWriteTests { .getRuntimeMetamodels() .getEntityMappingType( ReadWriteEntity.class ); final BasicValuedSingularAttributeMapping attribute = (BasicValuedSingularAttributeMapping) entityMapping.findAttributeMapping( "value" ); - attribute.forEachSelection( + attribute.forEachSelectable( (i, selectable) -> { final String readExpression = selectable.getCustomReadExpression(); }