HHH-13769: Avoid unnecessary joins

better support for lazy TableReference handling for collections;
removed TableReferenceCollector and TableReferenceContributor
This commit is contained in:
Steve Ebersole 2019-12-10 14:43:24 -06:00
parent dcbef8705c
commit 996157fca1
17 changed files with 36 additions and 779 deletions

View File

@ -18,13 +18,13 @@ import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.NavigablePath; import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase; import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
@ -240,19 +240,26 @@ public interface EntityMappingType extends ManagedMappingType, Loadable {
); );
} }
@Override default TableReference createPrimaryTableReference(
default void applyTableReferences(
SqlAliasBase sqlAliasBase, SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver, SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) { SqlAstCreationContext creationContext) {
getEntityPersister().applyTableReferences( throw new UnsupportedOperationException(
sqlAliasBase, "Entity mapping does not support primary TableReference creation [" +
baseSqlAstJoinType, getClass().getName() + " : " + getEntityName() + "]"
collector, );
sqlExpressionResolver, }
creationContext
default TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException(
"Entity mapping does not support primary TableReference join creation [" +
getClass().getName() + " : " + getEntityName() + "]"
); );
} }

View File

@ -16,16 +16,6 @@ import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
import org.hibernate.metamodel.mapping.ColumnConsumer; import org.hibernate.metamodel.mapping.ColumnConsumer;
import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityMappingType;
@ -39,7 +29,6 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -50,9 +39,15 @@ import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.CompositeTableGroup; import org.hibernate.sql.ast.tree.from.CompositeTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableGroupProducer;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
/** /**
@ -257,56 +252,6 @@ public class EmbeddedAttributeMapping
return tableGroupJoin; return tableGroupJoin;
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
getEmbeddableTypeDescriptor().visitAttributeMappings(
attrMapping -> {
if ( attrMapping instanceof TableGroupProducer ) {
( (TableGroupProducer) attrMapping ).applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
}
);
}
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedAttributeMapping#createPrimaryTableReference" );
}
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedAttributeMapping#createTableReferenceJoin" );
}
@Override @Override
public String getSqlAliasStem() { public String getSqlAliasStem() {
return getAttributeName(); return getAttributeName();

View File

@ -24,7 +24,6 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -35,9 +34,6 @@ import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.CompositeTableGroup; import org.hibernate.sql.ast.tree.from.CompositeTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.FetchParent;
@ -187,35 +183,6 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedF
); );
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
// nothing to do
}
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedCollectionPart#createPrimaryTableReference" );
}
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedCollectionPart#createTableReferenceJoin" );
}
@Override @Override
public String getSqlAliasStem() { public String getSqlAliasStem() {
return sqlAliasStem; return sqlAliasStem;

View File

@ -15,8 +15,6 @@ import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming; import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
import org.hibernate.metamodel.mapping.ColumnConsumer; import org.hibernate.metamodel.mapping.ColumnConsumer;
import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddedIdentifierMapping; import org.hibernate.metamodel.mapping.EmbeddedIdentifierMapping;
@ -31,7 +29,6 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstJoinType; import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator; import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
import org.hibernate.sql.ast.spi.SqlAstCreationContext; import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstCreationState;
@ -42,15 +39,14 @@ import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.CompositeTableGroup; import org.hibernate.sql.ast.tree.from.CompositeTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableGroupProducer;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch; import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration; import org.hibernate.type.spi.TypeConfiguration;
@ -232,56 +228,6 @@ public class EmbeddedIdentifierMappingImpl
getMappedTypeDescriptor().visitSubParts( consumer, treatTargetType ); getMappedTypeDescriptor().visitSubParts( consumer, treatTargetType );
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
getEmbeddableTypeDescriptor().visitAttributeMappings(
attrMapping -> {
if ( attrMapping instanceof TableGroupProducer ) {
( (TableGroupProducer) attrMapping ).applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
else if ( attrMapping.getMappedTypeDescriptor() instanceof TableGroupProducer ) {
( (TableGroupProducer) attrMapping.getMappedTypeDescriptor() ).applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
}
);
}
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedIdentifierImpl#createPrimaryTableReference" );
}
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Unexpected call to EmbeddedIdentifierImpl#createTableReferenceJoin" );
}
@Override @Override
public String getFetchableName() { public String getFetchableName() {
return name; return name;

View File

@ -47,7 +47,6 @@ import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin; import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
@ -456,7 +455,7 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
lockMode, lockMode,
primaryTableReference, primaryTableReference,
sqlAliasBase, sqlAliasBase,
(tableExpression, tg) -> createTableReferenceJoin( (tableExpression, tg) -> entityPartDescriptor.getEntityMappingType().createTableReferenceJoin(
tableExpression, tableExpression,
sqlAliasBase, sqlAliasBase,
primaryTableReference, primaryTableReference,
@ -542,7 +541,7 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
creationContext creationContext
); );
tableReferenceJoinCreator = (tableExpression, tableGroup) -> createTableReferenceJoin( tableReferenceJoinCreator = (tableExpression, tableGroup) -> mappingType.createTableReferenceJoin(
tableExpression, tableExpression,
sqlAliasBase, sqlAliasBase,
associatedPrimaryTable, associatedPrimaryTable,
@ -595,52 +594,6 @@ public class PluralAttributeMappingImpl extends AbstractAttributeMapping impleme
return tableGroup; return tableGroup;
} }
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
return getCollectionDescriptor().createTableReferenceJoin(
joinTableExpression,
sqlAliasBase,
lhs,
canUseInnerJoin,
sqlExpressionResolver,
creationContext
);
}
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
return getCollectionDescriptor().createPrimaryTableReference(
sqlAliasBase,
sqlExpressionResolver,
creationContext
);
}
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
getCollectionDescriptor().applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
@Override @Override
public TableGroup createRootTableGroup( public TableGroup createRootTableGroup(
NavigablePath navigablePath, NavigablePath navigablePath,

View File

@ -33,8 +33,6 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer; import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.sql.results.graph.DomainResultCreationState;
@ -207,7 +205,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
final String aliasRoot = explicitSourceAlias == null ? sqlAliasStem : explicitSourceAlias; final String aliasRoot = explicitSourceAlias == null ? sqlAliasStem : explicitSourceAlias;
final SqlAliasBase sqlAliasBase = aliasBaseGenerator.createSqlAliasBase( aliasRoot ); final SqlAliasBase sqlAliasBase = aliasBaseGenerator.createSqlAliasBase( aliasRoot );
final TableReference primaryTableReference = createPrimaryTableReference( final TableReference primaryTableReference = getEntityMappingType().createPrimaryTableReference(
sqlAliasBase, sqlAliasBase,
sqlExpressionResolver, sqlExpressionResolver,
creationContext creationContext
@ -219,7 +217,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
lockMode, lockMode,
primaryTableReference, primaryTableReference,
sqlAliasBase, sqlAliasBase,
(tableExpression, tg) -> createTableReferenceJoin( (tableExpression, tg) -> getEntityMappingType().createTableReferenceJoin(
tableExpression, tableExpression,
sqlAliasBase, sqlAliasBase,
primaryTableReference, primaryTableReference,
@ -256,48 +254,6 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
return sqlAliasStem; return sqlAliasStem;
} }
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
return getEntityMappingType().createPrimaryTableReference( sqlAliasBase, sqlExpressionResolver, creationContext );
}
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
return getEntityMappingType().createTableReferenceJoin(
joinTableExpression,
sqlAliasBase,
lhs,
canUseInnerJoin && ! getAttributeMetadataAccess().resolveAttributeMetadata( null ).isNullable(),
sqlExpressionResolver,
creationContext
);
}
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
getMappedTypeDescriptor().applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
@Override @Override
public boolean isCircular(FetchParent fetchParent, SqlAstProcessingState creationState) { public boolean isCircular(FetchParent fetchParent, SqlAstProcessingState creationState) {
final NavigablePath panentNaviblePath = fetchParent.getNavigablePath(); final NavigablePath panentNaviblePath = fetchParent.getNavigablePath();

View File

@ -10,14 +10,12 @@ import java.io.Serializable;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
@ -75,20 +73,11 @@ import org.hibernate.mapping.Selectable;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metadata.CollectionMetadata; import org.hibernate.metadata.CollectionMetadata;
import org.hibernate.metamodel.mapping.BasicEntityIdentifierMapping;
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl; import org.hibernate.metamodel.mapping.internal.PluralAttributeMappingImpl;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.PropertyMapping; import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.persister.entity.Queryable; import org.hibernate.persister.entity.Queryable;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
@ -104,23 +93,10 @@ import org.hibernate.persister.walking.spi.CompositeCollectionElementDefinition;
import org.hibernate.persister.walking.spi.CompositionDefinition; import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition; import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.query.ComparisonOperator;
import org.hibernate.sql.Alias; import org.hibernate.sql.Alias;
import org.hibernate.sql.SelectFragment; import org.hibernate.sql.SelectFragment;
import org.hibernate.sql.SimpleSelect; import org.hibernate.sql.SimpleSelect;
import org.hibernate.sql.Template; import org.hibernate.sql.Template;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceContributor;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.type.AnyType; import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType; import org.hibernate.type.AssociationType;
@ -2472,274 +2448,6 @@ public abstract class AbstractCollectionPersister
return false; return false;
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
if ( isOneToMany() ) {
// one-to-many does not define a "collection table"
assert elementPersister != null;
}
else {
collector.applyPrimaryReference(
new TableReference(
qualifiedTableName,
sqlAliasBase.generateNewAlias(),
false,
getFactory()
)
);
}
if ( elementPersister != null ) {
// apply the strategy for how to create the join predicate between the collection table
// and the entity's primary table. Only used when there is a collection-table.
//
// when triggered the `lhs` will be the collection-table and the `rhs` will be the
// entity's primary table
collector.applyPrimaryJoinProducer(
(lhs, rhs) -> new TableReferenceJoin(
baseSqlAstJoinType,
rhs,
generateEntityElementJoinPredicate(
lhs, rhs, baseSqlAstJoinType, sqlExpressionResolver, creationContext
)
)
);
elementPersister.applyTableReferences(
sqlAliasBase,
// todo (6.0) : determine the proper join-type to use
SqlAstJoinType.LEFT,
collector,
sqlExpressionResolver,
creationContext
);
}
final CollectionPart indexDescriptor = attributeMapping.getIndexDescriptor();
if ( indexDescriptor != null && indexDescriptor.getPartTypeDescriptor() instanceof TableReferenceContributor ) {
final TableReferenceContributor contributor = (TableReferenceContributor) indexDescriptor.getPartTypeDescriptor();
collector.applyPrimaryJoinProducer(
(lhs, rhs) -> new TableReferenceJoin(
baseSqlAstJoinType,
rhs,
generateIndexJoinPredicate(
lhs,
rhs,
SqlAstJoinType.CROSS,
sqlExpressionResolver,
creationContext
)
)
);
contributor.applyTableReferences(
sqlAliasBase,
baseSqlAstJoinType,
collector,
sqlExpressionResolver,
creationContext
);
}
}
private Predicate generateIndexJoinPredicate(
TableReference lhs,
TableReference rhs,
SqlAstJoinType sqlAstJoinType,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
final CollectionPart indexDescriptor = attributeMapping.getIndexDescriptor();
final MappingType indexMappingType = indexDescriptor.getPartTypeDescriptor();
assert indexMappingType instanceof EntityMappingType;
final EntityMappingType indexEntityType = (EntityMappingType) indexMappingType;
// `lhs` should be the collection-table or the primary element table (one-to-many)
// `rhs` is the primary table for the index
if ( isOneToMany() ) {
assert elementPersister != null;
assert lhs.getTableExpression().equals( ( (Joinable) elementPersister ).getTableName() );
}
else {
assert lhs.getTableExpression().equals( getTableName() );
}
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
final EntityIdentifierMapping identifierMapping = indexEntityType.getIdentifierMapping();
final int jdbcTypeCount = identifierMapping.getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
assert jdbcTypeCount == indexColumnNames.length;
if ( jdbcTypeCount == 1 ) {
assert identifierMapping instanceof BasicEntityIdentifierMapping;
assert elementColumnNames.length == 1;
final BasicEntityIdentifierMapping basicKeyMapping = (BasicEntityIdentifierMapping) identifierMapping;
return new ComparisonPredicate(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( lhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
lhs,
elementColumnNames[0],
basicKeyMapping.getJdbcMapping(),
sessionFactory
)
),
ComparisonOperator.EQUAL,
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( rhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
rhs,
basicKeyMapping.getMappedColumnExpression(),
basicKeyMapping.getJdbcMapping(),
sessionFactory
)
)
);
}
else {
final SqlTuple.Builder comparisonLhsBuilder = new SqlTuple.Builder( indexDescriptor, jdbcTypeCount );
final SqlTuple.Builder comparisonRhsBuilder = new SqlTuple.Builder( identifierMapping, jdbcTypeCount );
final AtomicInteger count = new AtomicInteger();
identifierMapping.visitColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
assert rhs.getTableExpression().equals( containingTableExpression );
int position = count.getAndIncrement();
comparisonRhsBuilder.addSubExpression(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( rhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
rhs,
columnExpression,
jdbcMapping,
sessionFactory
)
)
);
comparisonLhsBuilder.addSubExpression(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( lhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
lhs,
elementColumnNames[ position ],
jdbcMapping,
sessionFactory
)
)
);
}
);
final SqlTuple comparisionLhs = comparisonLhsBuilder.buildTuple();
final SqlTuple comparisonRhs = comparisonRhsBuilder.buildTuple();
return new ComparisonPredicate( comparisionLhs, ComparisonOperator.EQUAL, comparisonRhs );
}
}
private Predicate generateEntityElementJoinPredicate(
TableReference lhs,
TableReference rhs,
SqlAstJoinType baseSqlAstJoinType,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
final SessionFactoryImplementor sessionFactory = creationContext.getSessionFactory();
final String fkTargetModelPartName = getCollectionType().getRHSUniqueKeyPropertyName();
final ModelPart fkTargetDescriptor;
if ( fkTargetModelPartName != null ) {
fkTargetDescriptor = elementPersister.findSubPart( fkTargetModelPartName );
}
else {
fkTargetDescriptor = elementPersister.getIdentifierMapping();
}
final int jdbcTypeCount = fkTargetDescriptor.getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
assert jdbcTypeCount == elementColumnNames.length;
if ( jdbcTypeCount == 1 ) {
final BasicValuedModelPart fkModelPartType = (BasicValuedModelPart) fkTargetDescriptor;
return new ComparisonPredicate(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( lhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
lhs,
elementColumnNames[0],
fkModelPartType.getJdbcMapping(),
sessionFactory
)
),
ComparisonOperator.EQUAL,
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( rhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
rhs,
fkModelPartType.getMappedColumnExpression(),
fkModelPartType.getJdbcMapping(),
sessionFactory
)
)
);
}
else {
// todo (6.0) : tuple or disjunction?
// for now use a tuple - its easier to build, even though disjunction is more universally supported at DB level
final java.util.List<JdbcMapping> jdbcMappings = new ArrayList<>( jdbcTypeCount );
final SqlTuple.Builder comparisonRhsBuilder = new SqlTuple.Builder( fkTargetDescriptor, jdbcTypeCount );
fkTargetDescriptor.visitColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
assert rhs.getTableExpression().equals( containingTableExpression );
jdbcMappings.add( jdbcMapping );
comparisonRhsBuilder.addSubExpression(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( rhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
rhs,
columnExpression,
jdbcMapping,
sessionFactory
)
)
);
}
);
final SqlTuple comparisonRhs = comparisonRhsBuilder.buildTuple();
final SqlTuple.Builder comparisonLhsBuilder = new SqlTuple.Builder( fkTargetDescriptor, jdbcTypeCount );
for ( int i = 0; i < elementColumnNames.length; i++ ) {
final String lhsColumnName = elementColumnNames[i];
final JdbcMapping jdbcMapping = jdbcMappings.get( i );
comparisonLhsBuilder.addSubExpression(
sqlExpressionResolver.resolveSqlExpression(
SqlExpressionResolver.createColumnReferenceKey( lhs, elementColumnNames[0] ),
sqlAstProcessingState -> new ColumnReference(
lhs,
lhsColumnName,
jdbcMapping,
sessionFactory
)
)
);
}
final SqlTuple comparisionLhs = comparisonLhsBuilder.buildTuple();
return new ComparisonPredicate( comparisionLhs, ComparisonOperator.EQUAL, comparisonRhs );
}
}
@Override @Override
public CollectionSemantics getCollectionSemantics() { public CollectionSemantics getCollectionSemantics() {
return collectionSemantics; return collectionSemantics;

View File

@ -29,12 +29,6 @@ import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.metamodel.model.domain.NavigableRole; import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.CollectionDefinition; import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceContributor;
import org.hibernate.type.CollectionType; import org.hibernate.type.CollectionType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -72,7 +66,7 @@ import org.hibernate.type.Type;
* @see org.hibernate.collection.spi.PersistentCollection * @see org.hibernate.collection.spi.PersistentCollection
* @author Gavin King * @author Gavin King
*/ */
public interface CollectionPersister extends CollectionDefinition, TableReferenceContributor { public interface CollectionPersister extends CollectionDefinition {
NavigableRole getNavigableRole(); NavigableRole getNavigableRole();
/** /**
@ -376,20 +370,6 @@ public interface CollectionPersister extends CollectionDefinition, TableReferenc
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// mapping model // mapping model
@Override
default void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new NotYetImplementedFor6Exception(
"The persister used for this collection [" + getNavigableRole()
+ "] does not yet implement support for use in SQL AST creation;"
+ " should implement `TableReferenceContributor#applyTableReferences`"
);
}
default CollectionSemantics getCollectionSemantics() { default CollectionSemantics getCollectionSemantics() {
throw new NotYetImplementedFor6Exception( throw new NotYetImplementedFor6Exception(
"The persister used for this collection [" + getNavigableRole() "The persister used for this collection [" + getNavigableRole()

View File

@ -24,17 +24,11 @@ import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jdbc.Expectation; import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations; import org.hibernate.jdbc.Expectations;
import org.hibernate.mapping.Collection; import org.hibernate.mapping.Collection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable; import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.OuterJoinLoadable; import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.pretty.MessageHelper; import org.hibernate.pretty.MessageHelper;
import org.hibernate.sql.Update; import org.hibernate.sql.Update;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
/** /**
* Collection persister for one-to-many associations. * Collection persister for one-to-many associations.
@ -73,43 +67,6 @@ public class OneToManyPersister extends AbstractCollectionPersister {
keyIsUpdateable = collectionBinding.getKey().isUpdateable(); keyIsUpdateable = collectionBinding.getKey().isUpdateable();
} }
@Override
public TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
// for a one-to-many, the "primary table" is the primary table of the associated entity
final EntityPersister elementPersister = getElementPersister();
assert elementPersister != null;
return elementPersister.createPrimaryTableReference( sqlAliasBase, sqlExpressionResolver, creationContext );
}
@Override
public TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
final EntityPersister elementPersister = getElementPersister();
assert elementPersister != null;
assert qualifiedTableName != null;
assert lhs.getTableExpression().equals( qualifiedTableName );
assert lhs.getTableExpression().equals( ( (Joinable) elementPersister ).getTableName() );
return elementPersister.createTableReferenceJoin(
joinTableExpression,
sqlAliasBase,
lhs,
canUseInnerJoin,
sqlExpressionResolver,
creationContext
);
}
/** /**
* Generate the SQL UPDATE that updates all the foreign keys to null * Generate the SQL UPDATE that updates all the foreign keys to null
*/ */

View File

@ -184,7 +184,6 @@ import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.StandardTableGroup; import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin; import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate; import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
import org.hibernate.sql.ast.tree.predicate.Junction; import org.hibernate.sql.ast.tree.predicate.Junction;
@ -1324,30 +1323,6 @@ public abstract class AbstractEntityPersister
); );
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
final TableReference primaryTableReference = resolvePrimaryTableReference( sqlAliasBase );
collector.applyPrimaryReference( primaryTableReference );
for ( int i = 1; i < getSubclassTableSpan(); i++ ) {
collector.addTableReferenceJoin(
createTableReferenceJoin(
i,
primaryTableReference,
determineSubclassTableJoinType( i, true, true, null ),
sqlAliasBase,
sqlExpressionResolver
)
);
}
}
protected TableReferenceJoin createTableReferenceJoin( protected TableReferenceJoin createTableReferenceJoin(
int subClassTablePosition, int subClassTablePosition,
TableReference rootTableReference, TableReference rootTableReference,

View File

@ -15,7 +15,7 @@ import org.hibernate.sql.ast.spi.SqlAliasBaseManager;
* @author Steve Ebersole * @author Steve Ebersole
* @author Andrea Boriero * @author Andrea Boriero
*/ */
public interface TableGroupProducer extends ModelPartContainer, TableReferenceContributor { public interface TableGroupProducer extends ModelPartContainer {
/** /**
* Get the "stem" used as the base for generating SQL table aliases for table * Get the "stem" used as the base for generating SQL table aliases for table
* references that are part of the TableGroup being generated * references that are part of the TableGroup being generated

View File

@ -1,42 +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.sql.ast.tree.from;
import java.util.function.BiFunction;
import org.hibernate.sql.ast.SqlAstJoinType;
/**
* Used in constructing {@link TableGroup} references to collect the individual table
* references
*
* @author Steve Ebersole
*/
public interface TableReferenceCollector {
void applyPrimaryJoinProducer(BiFunction<TableReference, TableReference, TableReferenceJoin> primaryJoinProducer);
void applyPrimaryReference(TableReference tableReference);
/**
* Collect a table reference as part of the TableGroup.
*
* @param tableReference The TableReference.
* @param sqlAstJoinType The type of join indicated by the mapping of the table, if it is to be joined
* @param predicateProducer Function for creating the join predicate, if it is to be joined. The first
* argument passed to the function is the LHS reference. The second is the same as `tableReference`.
* The result is a SQL AST Predicate to use as the join-predicate
*/
void applySecondaryTableReferences(
TableReference tableReference,
SqlAstJoinType sqlAstJoinType,
TableReferenceJoinPredicateProducer predicateProducer);
/**
* Directly add a TableReferenceJoin
*/
void addTableReferenceJoin(TableReferenceJoin join);
}

View File

@ -1,44 +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.sql.ast.tree.from;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
/**
* @author Steve Ebersole
*/
public interface TableReferenceContributor {
/**
* Apply the Tables mapped by this producer to the collector as TableReferences
*/
void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext);
default TableReference createPrimaryTableReference(
SqlAliasBase sqlAliasBase,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Contributor [" + getClass().getName() + "] does not support primary TableReference creation" );
}
default TableReferenceJoin createTableReferenceJoin(
String joinTableExpression,
SqlAliasBase sqlAliasBase,
TableReference lhs,
boolean canUseInnerJoin,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new UnsupportedOperationException( "Contributor [" + getClass().getName() + "] does not support TableReference join creation" );
}
}

View File

@ -12,9 +12,6 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
/** /**
* Functional contract for producing the join-predicate related to a {@link TableReferenceJoin}. * Functional contract for producing the join-predicate related to a {@link TableReferenceJoin}.
* *
* @see TableReferenceJoin#getJoinPredicate
* @see TableReferenceCollector#applySecondaryTableReferences
*
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FunctionalInterface @FunctionalInterface

View File

@ -21,7 +21,6 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.cache.spi.access.NaturalIdDataAccess; import org.hibernate.cache.spi.access.NaturalIdDataAccess;
@ -59,11 +58,6 @@ import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition; import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition; import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl; import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer; import org.hibernate.tuple.entity.EntityTuplizer;
@ -723,16 +717,6 @@ public class PersisterClassProviderTest {
public JavaTypeDescriptor getMappedJavaTypeDescriptor() { public JavaTypeDescriptor getMappedJavaTypeDescriptor() {
return null; return null;
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new NotYetImplementedFor6Exception( getClass() );
}
} }
public static class GoofyException extends RuntimeException { public static class GoofyException extends RuntimeException {

View File

@ -20,7 +20,6 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.CollectionDataAccess; import org.hibernate.cache.spi.access.CollectionDataAccess;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
@ -59,11 +58,6 @@ import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.CollectionElementDefinition; import org.hibernate.persister.walking.spi.CollectionElementDefinition;
import org.hibernate.persister.walking.spi.CollectionIndexDefinition; import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition; import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl; import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer; import org.hibernate.tuple.entity.EntityTuplizer;
@ -709,16 +703,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
public JavaTypeDescriptor getMappedJavaTypeDescriptor() { public JavaTypeDescriptor getMappedJavaTypeDescriptor() {
return null; return null;
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new NotYetImplementedFor6Exception( getClass() );
}
} }
public static class NoopCollectionPersister implements CollectionPersister { public static class NoopCollectionPersister implements CollectionPersister {

View File

@ -21,7 +21,6 @@ import org.hibernate.HibernateException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata; import org.hibernate.bytecode.spi.BytecodeEnhancementMetadata;
import org.hibernate.cache.spi.access.EntityDataAccess; import org.hibernate.cache.spi.access.EntityDataAccess;
import org.hibernate.cache.spi.access.NaturalIdDataAccess; import org.hibernate.cache.spi.access.NaturalIdDataAccess;
@ -60,11 +59,6 @@ import org.hibernate.persister.entity.MultiLoadOptions;
import org.hibernate.persister.spi.PersisterCreationContext; import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition; import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition; import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.sql.ast.SqlAstJoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl; import org.hibernate.tuple.entity.BytecodeEnhancementMetadataNonPojoImpl;
import org.hibernate.tuple.entity.EntityMetamodel; import org.hibernate.tuple.entity.EntityMetamodel;
import org.hibernate.tuple.entity.EntityTuplizer; import org.hibernate.tuple.entity.EntityTuplizer;
@ -822,14 +816,4 @@ public class CustomPersister implements EntityPersister {
public JavaTypeDescriptor getMappedJavaTypeDescriptor() { public JavaTypeDescriptor getMappedJavaTypeDescriptor() {
return null; return null;
} }
@Override
public void applyTableReferences(
SqlAliasBase sqlAliasBase,
SqlAstJoinType baseSqlAstJoinType,
TableReferenceCollector collector,
SqlExpressionResolver sqlExpressionResolver,
SqlAstCreationContext creationContext) {
throw new NotYetImplementedFor6Exception( getClass() );
}
} }