Rename SelectionMapping(s) to SelectableMapping(s) and related changes

This commit is contained in:
Steve Ebersole 2021-03-31 11:21:51 -05:00
parent c7c963075b
commit 1a9079006c
63 changed files with 443 additions and 433 deletions

View File

@ -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<T> implements NaturalIdLoader<T> {
*/
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
)
);

View File

@ -52,11 +52,11 @@ public class CompoundNaturalIdLoader<T> extends AbstractNaturalIdLoader<T> {
if ( bindValue == null ) {
final List<SingularAttributeMapping> 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
);

View File

@ -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() );

View File

@ -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<ColumnReference> 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<ColumnReference> 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() );

View File

@ -67,11 +67,11 @@ public class SimpleNaturalIdLoader<T> extends AbstractNaturalIdLoader<T> {
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()
);

View File

@ -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<SingularAttributeMapping> 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<ColumnReference> columnReferences = CollectionHelper.arrayList( selectionMappings.getJdbcTypeCount() );
final SelectableMappings selectableMappings = getEmbeddableTypeDescriptor();
final List<ColumnReference> 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

View File

@ -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() {

View File

@ -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<AttributeMapping> 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<JdbcMapping> getJdbcMappings() {
return selectionMappings.getJdbcMappings();
return selectableMappings.getJdbcMappings();
}
@Override
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> 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

View File

@ -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

View File

@ -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<Consumer<SelectionConsumer>> tableKeyColumnVisitationSupplier);
void consume(String tableExpression, Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier);
}

View File

@ -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();

View File

@ -29,7 +29,7 @@ public class MappingModelHelper {
if ( modelPart instanceof EmbeddableValuedModelPart ) {
final List<ColumnReference> columnReferences = new ArrayList<>( jdbcTypeCount );
modelPart.forEachSelection(
modelPart.forEachSelectable(
(columnIndex, selection) -> {
final ColumnReference colRef;
if ( sqlExpressionResolver == null ) {

View File

@ -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);

View File

@ -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++
) {

View File

@ -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();

View File

@ -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<JdbcMapping> getJdbcMappings() {
final List<JdbcMapping> results = new ArrayList<>();
forEachSelectable( (index, selection) -> results.add( selection.getJdbcMapping() ) );
return results;
}
}

View File

@ -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<JdbcMapping> getJdbcMappings() {
final List<JdbcMapping> results = new ArrayList<>();
forEachSelection( (index, selection) -> results.add( selection.getJdbcMapping() ) );
return results;
}
}

View File

@ -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,

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<JdbcMapping> 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();
}

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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<ColumnReference> 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

View File

@ -169,7 +169,7 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF
final SqlExpressionResolver sqlExpressionResolver = sqlAstCreationState.getSqlExpressionResolver();
final List<Expression> expressions = new ArrayList<>();
getEmbeddableTypeDescriptor().forEachSelection(
getEmbeddableTypeDescriptor().forEachSelectable(
(columnIndex, selection) -> {
assert containingTableExpression.equals( selection.getContainingTableExpression() );
expressions.add(

View File

@ -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<SqlSelection> sqlSelections = new ArrayList<>( selectionMappings.getJdbcTypeCount() );
selectionMappings.forEachSelection(
final List<SqlSelection> 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<String> 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<SqlSelection> 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 )
);
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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<Selectable> 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
);
}

View File

@ -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()

View File

@ -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(),

View File

@ -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<JdbcMapping> 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<JdbcMapping> jdbcMappings = new ArrayList<>();
resolveJdbcMappings( jdbcMappings, mapping, value.getType() );
final List<SelectionMapping> selectionMappings = new ArrayList<>( jdbcMappings.size() );
final List<SelectableMapping> selectableMappings = new ArrayList<>( jdbcMappings.size() );
final Iterator<Selectable> 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<SelectionMapping> selectionMappings = CollectionHelper.arrayList( propertySpan );
final List<SelectableMapping> 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;
}
}

View File

@ -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 <T> DomainResult<T> 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<String> associationKeyColumns = Collections.singletonList( keySelectionMapping.getSelectionExpression() );
associationKey = new AssociationKey( keySelectionMapping.getContainingTableExpression(), associationKeyColumns );
final List<String> associationKeyColumns = Collections.singletonList( keySelectableMapping.getSelectionExpression() );
associationKey = new AssociationKey( keySelectableMapping.getContainingTableExpression(), associationKeyColumns );
}
return associationKey;
}
@Override
public List<JdbcMapping> getJdbcMappings() {
return Collections.singletonList( targetSelectionMapping.getJdbcMapping() );
return Collections.singletonList( targetSelectableMapping.getJdbcMapping() );
}
@Override
public int forEachJdbcType(int offset, IndexedConsumer<JdbcMapping> 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();
}
}

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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<AttributeMapping> 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;
}

View File

@ -85,7 +85,7 @@ public class MatchingIdSelectionHelper {
//noinspection rawtypes
final List<DomainResult> 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(

View File

@ -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<ColumnReference> 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<ColumnReference> 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,

View File

@ -140,15 +140,13 @@ public class CteUpdateHandler extends AbstractCteMutationHandler implements Upda
final TableReference dmlTableReference = updatingTableGroup.resolveTableReference( tableExpression );
final List<ColumnReference> 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,

View File

@ -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(

View File

@ -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() ),

View File

@ -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,

View File

@ -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<Consumer<SelectionConsumer>> tableKeyColumnVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier,
SqlExpressionResolver sqlExpressionResolver,
TableGroup rootTableGroup,
QuerySpec matchingIdSubQuerySpec,
@ -448,7 +448,7 @@ public class RestrictedDeleteExecutionDelegate implements TableBasedDeleteHandle
private void deleteFromTableUsingIdTable(
String tableExpression,
Supplier<Consumer<SelectionConsumer>> tableKeyColumnVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier,
QuerySpec idTableSubQuery,
ExecutionContext executionContext) {
log.tracef( "deleteFromTableUsingIdTable - %s", tableExpression );

View File

@ -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<Consumer<SelectionConsumer>> tableKeyColumnVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> tableKeyColumnVisitationSupplier,
QuerySpec idTableSubQuery,
ExecutionContext executionContext) {
final TableReference updatingTableReference = updatingTableGroup.resolveTableReference( tableExpression );

View File

@ -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<Consumer<SelectionConsumer>> columnsToMatchVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> columnsToMatchVisitationSupplier,
ExecutionContext executionContext) {
assert matchingIdValues != null;
assert ! matchingIdValues.isEmpty();
@ -87,7 +87,7 @@ public class DisjunctionRestrictionProducer implements MatchingIdRestrictionProd
else {
final List<ColumnReference> columnReferences = new ArrayList<>( idColumnCount );
final List<JdbcMapping> jdbcMappings = new ArrayList<>( idColumnCount );
identifierMapping.forEachSelection(
identifierMapping.forEachSelectable(
(columnIndex, selection) -> {
columnReferences.add(
new ColumnReference(

View File

@ -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<Consumer<SelectionConsumer>> columnsToMatchVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> columnsToMatchVisitationSupplier,
ExecutionContext executionContext) {
assert matchingIdValues != null;
assert ! matchingIdValues.isEmpty();
@ -84,7 +84,7 @@ public class InPredicateRestrictionProducer implements MatchingIdRestrictionProd
else {
final List<ColumnReference> columnReferences = new ArrayList<>( idColumnCount );
final List<JdbcMapping> jdbcMappings = new ArrayList<>( idColumnCount );
identifierMapping.forEachSelection(
identifierMapping.forEachSelectable(
(columnIndex, selection) -> {
columnReferences.add(
new ColumnReference(

View File

@ -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<Consumer<SelectionConsumer>> tableKeyColumnsVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> tableKeyColumnsVisitationSupplier,
List<Object> ids,
JdbcParameterBindings jdbcParameterBindings,
ExecutionContext executionContext) {

View File

@ -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<Consumer<SelectionConsumer>> columnsToMatchVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> columnsToMatchVisitationSupplier,
ExecutionContext executionContext);
}

View File

@ -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<Consumer<SelectionConsumer>> columnsToMatchVisitationSupplier,
Supplier<Consumer<SelectableConsumer>> 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

View File

@ -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<T extends Statement> 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<Expression> lhs = new ArrayList<>( jdbcTypeCount );
final List<Expression> 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
)
);

View File

@ -90,7 +90,7 @@ public class EntityValuedPathInterpretation<T> 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<T> 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()
)
)

View File

@ -39,7 +39,7 @@ public class CteTable {
public CteTable(String cteName, EntityMappingType entityDescriptor) {
final int numberOfColumns = entityDescriptor.getIdentifierMapping().getJdbcTypeCount();
final List<CteColumn> columns = new ArrayList<>( numberOfColumns );
entityDescriptor.getIdentifierMapping().forEachSelection(
entityDescriptor.getIdentifierMapping().forEachSelectable(
(columnIndex, selection) -> columns.add(
new CteColumn("cte_" + selection.getSelectionExpression(), selection.getJdbcMapping() )
)

View File

@ -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
);
}

View File

@ -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" )
);
}

View File

@ -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" ) );

View File

@ -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" ) );

View File

@ -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" ) );

View File

@ -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" ) );

View File

@ -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" ) );

View File

@ -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" ) );

View File

@ -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();
}