HHH-13763 : Update all load-by-key handling to use SQL AST

- Initial working support for the following load-by-key Loaders:

  * SingleIdEntityLoader
  * MultiIdEntityLoader
  * SingleKeyCollectionLoader
  * BatchKeyCollectionLoader
  * SubSelectFetchCollectionLoader
This commit is contained in:
Steve Ebersole 2019-12-02 12:12:54 -06:00
parent f836689be8
commit c96ad0dcea
351 changed files with 2752 additions and 2917 deletions

View File

@ -21,9 +21,9 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.collection.BagInitializerProducer;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.BagInitializerProducer;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole

View File

@ -20,9 +20,9 @@ import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.collection.MapInitializerProducer;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.MapInitializerProducer;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole

View File

@ -17,9 +17,9 @@ import org.hibernate.engine.FetchTiming;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.results.internal.domain.collection.SetInitializerProducer;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.SetInitializerProducer;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* @author Steve Ebersole

View File

@ -21,8 +21,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;
import org.jboss.logging.Logger;

View File

@ -23,8 +23,8 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;
/**

View File

@ -22,8 +22,8 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;
/**

View File

@ -20,8 +20,8 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;
/**

View File

@ -22,8 +22,8 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;

View File

@ -21,8 +21,8 @@ import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;

View File

@ -22,9 +22,9 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.collection.ArrayInitializerProducer;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.ArrayInitializerProducer;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* CollectionSemantics implementation for arrays

View File

@ -23,9 +23,9 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.collection.ListInitializerProducer;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.ListInitializerProducer;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* Hibernate's standard CollectionSemantics for Lists

View File

@ -11,11 +11,11 @@ import java.util.function.Consumer;
import org.hibernate.LockMode;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.results.spi.AssemblerCreationState;
import org.hibernate.sql.results.spi.CollectionInitializer;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.FetchParentAccess;
import org.hibernate.sql.results.spi.Initializer;
import org.hibernate.sql.results.graph.AssemblerCreationState;
import org.hibernate.sql.results.graph.collection.CollectionInitializer;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.FetchParentAccess;
import org.hibernate.sql.results.graph.Initializer;
/**
* Functional contract to create a CollectionInitializer

View File

@ -16,8 +16,8 @@ import org.hibernate.metamodel.CollectionClassification;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
/**
* Describes the semantics of a persistent collection such that Hibernate

View File

@ -16,8 +16,8 @@ import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.Type;
/**

View File

@ -21,7 +21,7 @@ import org.hibernate.UnknownProfileException;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.spi.RootGraphImplementor;
import org.hibernate.internal.FilterImpl;
import org.hibernate.loader.spi.CascadingFetchProfile;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.type.Type;
/**

View File

@ -10,8 +10,9 @@ import java.util.List;
import java.util.Set;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
/**
@ -21,6 +22,7 @@ import org.hibernate.sql.exec.spi.JdbcParameterBindings;
public class SubselectFetch {
private final EntityValuedModelPart entityModelPart;
private final QuerySpec loadingSqlAst;
private final TableGroup ownerTableGroup;
private final List<JdbcParameter> loadingJdbcParameters;
private final JdbcParameterBindings loadingJdbcParameterBindings;
private final Set<EntityKey> resultingEntityKeys;
@ -28,11 +30,13 @@ public class SubselectFetch {
public SubselectFetch(
EntityValuedModelPart entityModelPart,
QuerySpec loadingSqlAst,
TableGroup ownerTableGroup,
List<JdbcParameter> loadingJdbcParameters,
JdbcParameterBindings loadingJdbcParameterBindings,
Set<EntityKey> resultingEntityKeys) {
this.entityModelPart = entityModelPart;
this.loadingSqlAst = loadingSqlAst;
this.ownerTableGroup = ownerTableGroup;
this.loadingJdbcParameters = loadingJdbcParameters;
this.loadingJdbcParameterBindings = loadingJdbcParameterBindings;
this.resultingEntityKeys = resultingEntityKeys;
@ -46,6 +50,10 @@ public class SubselectFetch {
return loadingSqlAst;
}
public TableGroup getOwnerTableGroup() {
return ownerTableGroup;
}
public List<JdbcParameter> getLoadingJdbcParameters() {
return loadingJdbcParameters;
}

View File

@ -34,7 +34,7 @@ import org.hibernate.event.spi.MergeEvent;
import org.hibernate.event.spi.MergeEventListener;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.spi.CascadingFetchProfile;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;

View File

@ -30,7 +30,7 @@ import org.hibernate.event.spi.RefreshEvent;
import org.hibernate.event.spi.RefreshEventListener;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.loader.spi.CascadingFetchProfile;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.metamodel.spi.MetamodelImplementor;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;

View File

@ -9,10 +9,10 @@ package org.hibernate.internal;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.query.spi.ScrollableResultsImplementor;
import org.hibernate.sql.results.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl;
import org.hibernate.sql.results.spi.JdbcValues;
import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.jdbc.spi.JdbcValues;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.spi.RowReader;
/**

View File

@ -9,10 +9,10 @@ package org.hibernate.internal;
import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.sql.results.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl;
import org.hibernate.sql.results.spi.JdbcValues;
import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.jdbc.spi.JdbcValues;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.spi.RowReader;
/**

View File

@ -12,10 +12,10 @@ import org.hibernate.HibernateException;
import org.hibernate.JDBCException;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.sql.results.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl;
import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl;
import org.hibernate.sql.results.spi.JdbcValues;
import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.jdbc.spi.JdbcValues;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
import org.hibernate.sql.results.spi.RowReader;
/**

View File

@ -53,6 +53,11 @@ public class SingletonStack<T> implements Stack<T> {
public void clear() {
}
@Override
public void visitRootFirst(Consumer<T> action) {
action.accept( instance );
}
@Override
public void visitCurrentFirst(Consumer<T> action) {
action.accept( instance );

View File

@ -52,6 +52,11 @@ public interface Stack<T> {
*/
void clear();
/**
* Visit all elements in the stack, starting with the root and working "forward"
*/
void visitRootFirst(Consumer<T> action);
/**
* Visit all elements in the stack, starting with the current and working back
*/

View File

@ -103,6 +103,19 @@ public class StandardStack<T> implements Stack<T> {
}
}
@Override
public void visitRootFirst(Consumer<T> action) {
if ( internalStack != null ) {
final int stackSize = internalStack.size();
for ( int i = stackSize - 1; i >= 0; i-- ) {
action.accept( internalStack.get( i ) );
}
}
if ( current != null ) {
action.accept( current );
}
}
@Override
public void visitCurrentFirst(Consumer<T> action) {
if ( current != null ) {

View File

@ -15,7 +15,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@ -47,7 +46,6 @@ import org.hibernate.engine.internal.TwoPhaseLoad;
import org.hibernate.engine.jdbc.ColumnNameCache;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.BatchFetchQueue;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.EntityUniqueKey;
@ -58,7 +56,6 @@ import org.hibernate.engine.spi.PersistentAttributeInterceptor;
import org.hibernate.engine.spi.RowSelection;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.SubselectFetch;
import org.hibernate.engine.spi.TypedValue;
import org.hibernate.event.service.spi.EventListenerGroup;
import org.hibernate.event.service.spi.EventListenerRegistry;
@ -73,7 +70,7 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.entity.CascadeEntityLoader;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
@ -19,7 +19,7 @@ import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.loader.spi.CollectionLoader;
import org.hibernate.loader.ast.spi.CollectionLoader;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.spi.QueryOptions;
@ -30,7 +30,7 @@ import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
@ -41,8 +41,8 @@ import org.jboss.logging.Logger;
/**
* @author Steve Ebersole
*/
public class BatchCollectionKeyLoader implements CollectionLoader {
private static final Logger log = Logger.getLogger( BatchCollectionKeyLoader.class );
public class BatchKeyCollectionLoader implements CollectionLoader {
private static final Logger log = Logger.getLogger( BatchKeyCollectionLoader.class );
private final PluralAttributeMapping attributeMapping;
private final int batchSize;
@ -52,7 +52,7 @@ public class BatchCollectionKeyLoader implements CollectionLoader {
private SelectStatement batchSizeSqlAst;
private List<JdbcParameter> batchSizeJdbcParameters;
public BatchCollectionKeyLoader(
public BatchKeyCollectionLoader(
PluralAttributeMapping attributeMapping,
int batchSize,
LoadQueryInfluencers influencers,
@ -63,7 +63,7 @@ public class BatchCollectionKeyLoader implements CollectionLoader {
this.keyJdbcCount = attributeMapping.getKeyDescriptor().getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
this.batchSizeJdbcParameters = new ArrayList<>();
this.batchSizeSqlAst = MetamodelSelectBuilderProcess.createSelect(
this.batchSizeSqlAst = LoaderSelectBuilder.createSelect(
attributeMapping,
null,
attributeMapping.getKeyDescriptor(),
@ -93,7 +93,7 @@ public class BatchCollectionKeyLoader implements CollectionLoader {
if ( numberOfIds == 1 ) {
final List<JdbcParameter> jdbcParameters = new ArrayList<>( keyJdbcCount );
final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect(
final SelectStatement sqlAst = LoaderSelectBuilder.createSelect(
attributeMapping,
null,
attributeMapping.getKeyDescriptor(),
@ -139,7 +139,7 @@ public class BatchCollectionKeyLoader implements CollectionLoader {
}
else {
jdbcParameters = new ArrayList<>();
sqlAst = MetamodelSelectBuilderProcess.createSelect(
sqlAst = LoaderSelectBuilder.createSelect(
getLoadable(),
// null here means to select everything
null,

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
@ -39,13 +39,13 @@ import org.hibernate.sql.exec.internal.JdbcParameterImpl;
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.graph.basic.BasicResult;
import org.hibernate.sql.results.graph.DomainResult;
import org.jboss.logging.Logger;

View File

@ -4,9 +4,9 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.sql.ast.tree.select.SelectStatement;
@ -16,7 +16,18 @@ import org.hibernate.sql.ast.tree.select.SelectStatement;
* @author Steve Ebersole
*/
public interface LoadPlan {
/**
* The thing being loaded
*/
Loadable getLoadable();
/**
* The part of the thing being loaded used to restrict which loadables get loaded
*/
ModelPart getRestrictivePart();
/**
* The SQL AST for the load
*/
SelectStatement getSqlAst();
}

View File

@ -4,11 +4,12 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
import org.hibernate.LockMode;
@ -18,7 +19,8 @@ import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SubselectFetch;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.loader.ast.spi.Loader;
import org.hibernate.metamodel.mapping.BasicValuedModelPart;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.JdbcMapping;
@ -31,8 +33,10 @@ import org.hibernate.sql.ast.spi.SimpleFromClauseAccessImpl;
import org.hibernate.sql.ast.spi.SqlAliasBaseManager;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.SqlTuple;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
@ -42,26 +46,40 @@ import org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate;
import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.internal.JdbcParameterImpl;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.results.graph.DomainResult;
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.FetchableContainer;
import org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult;
import org.hibernate.sql.results.internal.SqlSelectionImpl;
import org.hibernate.sql.results.internal.domain.collection.CollectionDomainResult;
import org.hibernate.sql.results.spi.CircularFetchDetector;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.jboss.logging.Logger;
import static org.hibernate.sql.ast.spi.SqlExpressionResolver.createColumnReferenceKey;
/**
* Builder for SQL AST trees used by {@link Loader} implementations.
*
* @author Steve Ebersole
*/
public class MetamodelSelectBuilderProcess {
private static final Logger log = Logger.getLogger( MetamodelSelectBuilderProcess.class );
public class LoaderSelectBuilder {
private static final Logger log = Logger.getLogger( LoaderSelectBuilder.class );
/**
* Create a SQL AST select-statement based on matching one-or-more keys
*
* @param loadable The root Loadable
* @param partsToSelect Parts of the Loadable to select. Null/empty indicates to select the Loadable itself
* @param restrictedPart Part to base the where-clause restriction on
* @param cachedDomainResult DomainResult to be used. Null indicates to generate the DomainResult
* @param numberOfKeysToLoad How many keys should be accounted for in the where-clause restriction?
* @param loadQueryInfluencers Any influencers (entity graph, fetch profile) to account for
* @param lockOptions Pessimistic lock options to apply
* @param jdbcParameterConsumer Consumer for all JdbcParameter references created
* @param sessionFactory The SessionFactory
*/
public static SelectStatement createSelect(
Loadable loadable,
List<ModelPart> partsToSelect,
@ -72,7 +90,7 @@ public class MetamodelSelectBuilderProcess {
LockOptions lockOptions,
Consumer<JdbcParameter> jdbcParameterConsumer,
SessionFactoryImplementor sessionFactory) {
final MetamodelSelectBuilderProcess process = new MetamodelSelectBuilderProcess(
final LoaderSelectBuilder process = new LoaderSelectBuilder(
sessionFactory,
loadable,
partsToSelect,
@ -87,6 +105,19 @@ public class MetamodelSelectBuilderProcess {
return process.generateSelect();
}
/**
* Create a SQL AST select-statement used for subselect-based CollectionLoader
*
* @see SubSelectFetchCollectionLoader
*
* @param attributeMapping The plural-attribute being loaded
* @param subselect The subselect details to apply
* @param cachedDomainResult DomainResult to be used. Null indicates to generate the DomainResult?
* @param loadQueryInfluencers Any influencers (entity graph, fetch profile) to account for
* @param lockOptions Pessimistic lock options to apply
* @param jdbcParameterConsumer Consumer for all JdbcParameter references created
* @param sessionFactory The SessionFactory
*/
public static SelectStatement createSubSelectFetchSelect(
PluralAttributeMapping attributeMapping,
SubselectFetch subselect,
@ -95,7 +126,7 @@ public class MetamodelSelectBuilderProcess {
LockOptions lockOptions,
Consumer<JdbcParameter> jdbcParameterConsumer,
SessionFactoryImplementor sessionFactory) {
final MetamodelSelectBuilderProcess process = new MetamodelSelectBuilderProcess(
final LoaderSelectBuilder process = new LoaderSelectBuilder(
sessionFactory,
attributeMapping,
null,
@ -121,7 +152,7 @@ public class MetamodelSelectBuilderProcess {
private final Consumer<JdbcParameter> jdbcParameterConsumer;
private MetamodelSelectBuilderProcess(
private LoaderSelectBuilder(
SqlAstCreationContext creationContext,
Loadable loadable,
List<ModelPart> partsToSelect,
@ -142,203 +173,7 @@ public class MetamodelSelectBuilderProcess {
this.jdbcParameterConsumer = jdbcParameterConsumer;
}
private SelectStatement generateSelect(SubselectFetch subselect) {
// todo (6.0) : i think we may even be able to convert this to a join by piecing together
// parts from the subselect-fetch sql-ast..
// todo (6.0) : ^^ another interesting idea is to use `partsToSelect` here relative to the owner
// - so `loadable` is the owner entity-descriptor and the `partsToSelect` is the collection
assert loadable instanceof PluralAttributeMapping;
final PluralAttributeMapping attributeMapping = (PluralAttributeMapping) loadable;
final QuerySpec rootQuerySpec = new QuerySpec( true );
final NavigablePath rootNavigablePath = new NavigablePath( loadable.getRootPathName() );
final LoaderSqlAstCreationState sqlAstCreationState = new LoaderSqlAstCreationState(
rootQuerySpec,
new SqlAliasBaseManager(),
new SimpleFromClauseAccessImpl(),
lockOptions,
this::visitFetches,
creationContext
);
// todo (6.0) : I think we want to continue to assign aliases to these table-references. we just want
// to control how that gets rendered in the walker
final TableGroup rootTableGroup = loadable.createRootTableGroup(
rootNavigablePath,
null,
null,
lockOptions.getLockMode(),
sqlAstCreationState.getSqlAliasBaseManager(),
sqlAstCreationState.getSqlExpressionResolver(),
() -> rootQuerySpec::applyPredicate,
creationContext
);
rootQuerySpec.getFromClause().addRoot( rootTableGroup );
sqlAstCreationState.getFromClauseAccess().registerTableGroup( rootNavigablePath, rootTableGroup );
// generate and apply the restriction
applySubSelectRestriction(
rootQuerySpec,
rootNavigablePath,
rootTableGroup,
subselect,
sqlAstCreationState
);
// register the jdbc-parameters
subselect.getLoadingJdbcParameters().forEach( jdbcParameterConsumer );
return new SelectStatement(
rootQuerySpec,
Collections.singletonList(
new CollectionDomainResult(
rootNavigablePath,
attributeMapping,
null,
rootTableGroup,
sqlAstCreationState
)
)
);
}
private void applySubSelectRestriction(
QuerySpec querySpec,
NavigablePath rootNavigablePath,
TableGroup rootTableGroup,
SubselectFetch subselect,
LoaderSqlAstCreationState sqlAstCreationState) {
final SqlAstCreationContext sqlAstCreationContext = sqlAstCreationState.getCreationContext();
final SessionFactoryImplementor sessionFactory = sqlAstCreationContext.getSessionFactory();
assert loadable instanceof PluralAttributeMapping;
assert restrictedPart == null || restrictedPart instanceof ForeignKeyDescriptor;
final PluralAttributeMapping attributeMapping = (PluralAttributeMapping) loadable;
final ForeignKeyDescriptor fkDescriptor = attributeMapping.getKeyDescriptor();
final Expression fkExpression;
final int jdbcTypeCount = fkDescriptor.getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
if ( jdbcTypeCount == 1 ) {
assert fkDescriptor instanceof SimpleForeignKeyDescriptor;
final SimpleForeignKeyDescriptor simpleFkDescriptor = (SimpleForeignKeyDescriptor) fkDescriptor;
fkExpression = sqlAstCreationState.getSqlExpressionResolver().resolveSqlExpression(
createColumnReferenceKey(
simpleFkDescriptor.getContainingTableExpression(),
simpleFkDescriptor.getMappedColumnExpression()
),
sqlAstProcessingState -> new ColumnReference(
rootTableGroup.resolveTableReference( simpleFkDescriptor.getContainingTableExpression() ),
simpleFkDescriptor.getMappedColumnExpression(),
simpleFkDescriptor.getJdbcMapping(),
this.creationContext.getSessionFactory()
)
);
}
else {
final List<ColumnReference> columnReferences = new ArrayList<>( jdbcTypeCount );
fkDescriptor.visitColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
columnReferences.add(
(ColumnReference) sqlAstCreationState.getSqlExpressionResolver().resolveSqlExpression(
createColumnReferenceKey( containingTableExpression, columnExpression ),
sqlAstProcessingState -> new ColumnReference(
rootTableGroup.resolveTableReference( containingTableExpression ),
columnExpression,
jdbcMapping,
this.creationContext.getSessionFactory()
)
)
);
}
);
fkExpression = new SqlTuple( columnReferences, fkDescriptor );
}
querySpec.applyPredicate(
new InSubQueryPredicate(
fkExpression,
generateSubSelect( attributeMapping, subselect, jdbcTypeCount, sqlAstCreationContext, sessionFactory ),
false
)
);
}
private QuerySpec generateSubSelect(
PluralAttributeMapping attributeMapping,
SubselectFetch subselect,
int jdbcTypeCount,
SqlAstCreationContext sqlAstCreationContext,
SessionFactoryImplementor sessionFactory) {
final ForeignKeyDescriptor fkDescriptor = attributeMapping.getKeyDescriptor();
final QuerySpec subQuery = new QuerySpec( false );
final QuerySpec loadingSqlAst = subselect.getLoadingSqlAst();
// transfer the from-clause
loadingSqlAst.getFromClause().visitRoots( subQuery.getFromClause()::addRoot );
// todo (6.0) : need to know the ColumnReference/TableReference part for the sub-query selection
// for now we hope to get lucky and use the un-qualified name
if ( jdbcTypeCount == 1 ) {
assert fkDescriptor instanceof SimpleForeignKeyDescriptor;
final SimpleForeignKeyDescriptor simpleFkDescriptor = (SimpleForeignKeyDescriptor) fkDescriptor;
subQuery.getSelectClause().addSqlSelection(
new SqlSelectionImpl(
1,
0,
new ColumnReference(
(String) null,
simpleFkDescriptor.getTargetColumnExpression(),
simpleFkDescriptor.getJdbcMapping(),
sessionFactory
),
simpleFkDescriptor.getJdbcMapping()
)
);
}
else {
final List<ColumnReference> columnReferences = new ArrayList<>( jdbcTypeCount );
fkDescriptor.visitTargetColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
columnReferences.add(
new ColumnReference(
(String) null,
columnExpression,
jdbcMapping,
sessionFactory
)
);
}
);
subQuery.getSelectClause().addSqlSelection(
new SqlSelectionImpl(
1,
0,
new SqlTuple( columnReferences, fkDescriptor ),
null
)
);
}
// transfer the restriction
subQuery.applyPredicate( loadingSqlAst.getWhereClauseRestrictions() );
return subQuery;
}
private SelectStatement generateSelect() {
final QuerySpec rootQuerySpec = new QuerySpec( true );
@ -585,6 +420,195 @@ public class MetamodelSelectBuilderProcess {
referencedMappingContainer.visitFetchables( processor, null );
return fetches;
} private SelectStatement generateSelect(SubselectFetch subselect) {
// todo (6.0) : i think we may even be able to convert this to a join by piecing together
// parts from the subselect-fetch sql-ast..
// todo (6.0) : ^^ another interesting idea is to use `partsToSelect` here relative to the owner
// - so `loadable` is the owner entity-descriptor and the `partsToSelect` is the collection
assert loadable instanceof PluralAttributeMapping;
final PluralAttributeMapping attributeMapping = (PluralAttributeMapping) loadable;
final QuerySpec rootQuerySpec = new QuerySpec( true );
final NavigablePath rootNavigablePath = new NavigablePath( loadable.getRootPathName() );
final LoaderSqlAstCreationState sqlAstCreationState = new LoaderSqlAstCreationState(
rootQuerySpec,
new SqlAliasBaseManager(),
new SimpleFromClauseAccessImpl(),
lockOptions,
this::visitFetches,
creationContext
);
// todo (6.0) : I think we want to continue to assign aliases to these table-references. we just want
// to control how that gets rendered in the walker
final TableGroup rootTableGroup = loadable.createRootTableGroup(
rootNavigablePath,
null,
null,
lockOptions.getLockMode(),
sqlAstCreationState.getSqlAliasBaseManager(),
sqlAstCreationState.getSqlExpressionResolver(),
() -> rootQuerySpec::applyPredicate,
creationContext
);
rootQuerySpec.getFromClause().addRoot( rootTableGroup );
sqlAstCreationState.getFromClauseAccess().registerTableGroup( rootNavigablePath, rootTableGroup );
// generate and apply the restriction
applySubSelectRestriction(
rootQuerySpec,
rootNavigablePath,
rootTableGroup,
subselect,
sqlAstCreationState
);
// register the jdbc-parameters
subselect.getLoadingJdbcParameters().forEach( jdbcParameterConsumer );
return new SelectStatement(
rootQuerySpec,
Collections.singletonList(
new CollectionDomainResult(
rootNavigablePath,
attributeMapping,
null,
rootTableGroup,
sqlAstCreationState
)
)
);
}
private void applySubSelectRestriction(
QuerySpec querySpec,
NavigablePath rootNavigablePath,
TableGroup rootTableGroup,
SubselectFetch subselect,
LoaderSqlAstCreationState sqlAstCreationState) {
final SqlAstCreationContext sqlAstCreationContext = sqlAstCreationState.getCreationContext();
final SessionFactoryImplementor sessionFactory = sqlAstCreationContext.getSessionFactory();
assert loadable instanceof PluralAttributeMapping;
assert restrictedPart == null || restrictedPart instanceof ForeignKeyDescriptor;
final PluralAttributeMapping attributeMapping = (PluralAttributeMapping) loadable;
final ForeignKeyDescriptor fkDescriptor = attributeMapping.getKeyDescriptor();
final Expression fkExpression;
final int jdbcTypeCount = fkDescriptor.getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
if ( jdbcTypeCount == 1 ) {
assert fkDescriptor instanceof SimpleForeignKeyDescriptor;
final SimpleForeignKeyDescriptor simpleFkDescriptor = (SimpleForeignKeyDescriptor) fkDescriptor;
fkExpression = sqlAstCreationState.getSqlExpressionResolver().resolveSqlExpression(
createColumnReferenceKey(
simpleFkDescriptor.getContainingTableExpression(),
simpleFkDescriptor.getMappedColumnExpression()
),
sqlAstProcessingState -> new ColumnReference(
rootTableGroup.resolveTableReference( simpleFkDescriptor.getContainingTableExpression() ),
simpleFkDescriptor.getMappedColumnExpression(),
simpleFkDescriptor.getJdbcMapping(),
this.creationContext.getSessionFactory()
)
);
}
else {
final List<ColumnReference> columnReferences = new ArrayList<>( jdbcTypeCount );
fkDescriptor.visitColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
columnReferences.add(
(ColumnReference) sqlAstCreationState.getSqlExpressionResolver().resolveSqlExpression(
createColumnReferenceKey( containingTableExpression, columnExpression ),
sqlAstProcessingState -> new ColumnReference(
rootTableGroup.resolveTableReference( containingTableExpression ),
columnExpression,
jdbcMapping,
this.creationContext.getSessionFactory()
)
)
);
}
);
fkExpression = new SqlTuple( columnReferences, fkDescriptor );
}
querySpec.applyPredicate(
new InSubQueryPredicate(
fkExpression,
generateSubSelect(
attributeMapping,
rootTableGroup,
subselect,
jdbcTypeCount,
sqlAstCreationState,
sessionFactory
),
false
)
);
}
private QuerySpec generateSubSelect(
PluralAttributeMapping attributeMapping,
TableGroup rootTableGroup,
SubselectFetch subselect,
int jdbcTypeCount,
LoaderSqlAstCreationState creationState,
SessionFactoryImplementor sessionFactory) {
final ForeignKeyDescriptor fkDescriptor = attributeMapping.getKeyDescriptor();
final QuerySpec subQuery = new QuerySpec( false );
final QuerySpec loadingSqlAst = subselect.getLoadingSqlAst();
// todo (6.0) : we need to find the owner's TableGroup in the `loadingSqlAst`
final TableGroup ownerTableGroup = subselect.getOwnerTableGroup();
// transfer the from-clause
loadingSqlAst.getFromClause().visitRoots( subQuery.getFromClause()::addRoot );
final SqlExpressionResolver sqlExpressionResolver = creationState.getSqlExpressionResolver();
final AtomicInteger count = new AtomicInteger();
fkDescriptor.visitTargetColumns(
(containingTableExpression, columnExpression, jdbcMapping) -> {
// for each column, resolve a SqlSelection and add it to the sub-query select-clause
final TableReference tableReference = ownerTableGroup.resolveTableReference( containingTableExpression );
final Expression expression = sqlExpressionResolver.resolveSqlExpression(
createColumnReferenceKey( tableReference, columnExpression ),
sqlAstProcessingState -> new ColumnReference(
tableReference,
columnExpression,
jdbcMapping,
sessionFactory
)
);
final int valuesPosition = count.getAndIncrement();
subQuery.getSelectClause().addSqlSelection(
new SqlSelectionImpl(
valuesPosition + 1,
valuesPosition,
expression,
jdbcMapping
)
);
}
);
// transfer the restriction
subQuery.applyPredicate( loadingSqlAst.getWhereClauseRestrictions() );
return subQuery;
}
}

View File

@ -4,17 +4,15 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.Collections;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Function;
import javax.persistence.CacheRetrieveMode;
import javax.persistence.CacheStoreMode;
import org.hibernate.CacheMode;
import org.hibernate.FlushMode;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
@ -36,15 +34,16 @@ import org.hibernate.sql.ast.spi.SqlAstProcessingState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
/**
* Helper used when generating the database-snapshot select query
*/
public class LoaderSqlAstCreationState
implements SqlAstProcessingState, SqlAstCreationState, DomainResultCreationState, QueryOptions {
private final QuerySpec querySpec;
private final SqlAliasBaseManager sqlAliasBaseManager;
private final SqlAstCreationContext sf;
private final SqlAstQuerySpecProcessingStateImpl processingState;
@ -59,6 +58,7 @@ public class LoaderSqlAstCreationState
LockOptions lockOptions,
BiFunction<FetchParent, LoaderSqlAstCreationState, List<Fetch>> fetchProcessor,
SqlAstCreationContext sf) {
this.querySpec = querySpec;
this.sqlAliasBaseManager = sqlAliasBaseManager;
this.fromClauseAccess = fromClauseAccess;
this.lockOptions = lockOptions;
@ -88,6 +88,10 @@ public class LoaderSqlAstCreationState
);
}
public QuerySpec getQuerySpec() {
return querySpec;
}
@Override
public SqlAstCreationContext getCreationContext() {
return sf;

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.lang.reflect.Array;
import java.util.ArrayList;
@ -31,7 +31,7 @@ import org.hibernate.event.spi.LoadEvent;
import org.hibernate.event.spi.LoadEventListener;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.entity.CacheEntityLoaderHelper;
import org.hibernate.loader.spi.MultiIdEntityLoader;
import org.hibernate.loader.ast.spi.MultiIdEntityLoader;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.persister.entity.EntityPersister;
@ -46,12 +46,12 @@ import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
import org.hibernate.sql.results.spi.LoadingEntityEntry;
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
import org.jboss.logging.Logger;
@ -237,7 +237,7 @@ public class MultiIdEntityLoaderStandardImpl<T> implements MultiIdEntityLoader<T
final List<JdbcParameter> jdbcParameters = new ArrayList<>( numberOfIdsInBatch * idJdbcTypeCount);
final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect(
final SelectStatement sqlAst = LoaderSelectBuilder.createSelect(
getLoadable(),
// null here means to select everything
null,
@ -341,7 +341,7 @@ public class MultiIdEntityLoaderStandardImpl<T> implements MultiIdEntityLoader<T
}
private static class LoadingEntityCollector {
final SubselectFetch subselectFetch;
private final SubselectFetch subselectFetch;
private final BatchFetchQueue batchFetchQueue;
LoadingEntityCollector(
@ -351,9 +351,10 @@ public class MultiIdEntityLoaderStandardImpl<T> implements MultiIdEntityLoader<T
JdbcParameterBindings jdbcParameterBindings,
BatchFetchQueue batchFetchQueue) {
this.batchFetchQueue = batchFetchQueue;
subselectFetch = new SubselectFetch(
this.subselectFetch = new SubselectFetch(
loadingEntityDescriptor,
loadingSqlAst,
loadingSqlAst.getFromClause().getRoots().get( 0 ),
jdbcParameters,
jdbcParameterBindings,
new HashSet<>()

View File

@ -4,11 +4,11 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.NaturalIdLoader;
import org.hibernate.loader.ast.spi.NaturalIdLoader;
import org.hibernate.persister.entity.EntityPersister;
/**

View File

@ -0,0 +1,22 @@
/*
* 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.loader.ast.internal;
/**
* Contract for Loader instances wishing to have a "finish initialization" callback after its Loadable
* has finished initializing.
*
* This allows the owner to create the Loader during its construction and trigger its "prepare" later
*
* @author Steve Ebersole
*/
public interface Preparable {
/**
* Perform the preparation
*/
void prepare();
}

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
/**
* Defines a plan for loading a single entity - by id, by uk, etc

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
@ -29,7 +29,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
@ -88,7 +88,7 @@ public class SingleIdEntityLoaderDynamicBatch<T> extends SingleIdEntityLoaderSup
final List<JdbcParameter> jdbcParameters = new ArrayList<>();
final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect(
final SelectStatement sqlAst = LoaderSelectBuilder.createSelect(
getLoadable(),
// null here means to select everything
null,

View File

@ -4,12 +4,12 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.SingleIdEntityLoader;
import org.hibernate.loader.ast.spi.SingleIdEntityLoader;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.query.named.NamedQueryProducer;
import org.hibernate.query.named.NamedQueryRepository;

View File

@ -4,22 +4,23 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.hibernate.Internal;
import org.hibernate.LockMode;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.CascadingFetchProfile;
import org.hibernate.loader.ast.spi.CascadingFetchProfile;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
/**
* Standard implementation of SingleIdEntityLoader
@ -52,15 +53,20 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
@Override
public T load(Object key, LockOptions lockOptions, SharedSessionContractImplementor session) {
final SingleIdLoadPlan<T> loadPlan = resolveLoadPlan( lockOptions, session );
final SingleIdLoadPlan<T> loadPlan = resolveLoadPlan(
lockOptions,
session.getLoadQueryInfluencers(),
session.getFactory()
);
return loadPlan.load( key, lockOptions, session );
}
private SingleIdLoadPlan<T> resolveLoadPlan(
@Internal
public SingleIdLoadPlan<T> resolveLoadPlan(
LockOptions lockOptions,
SharedSessionContractImplementor session) {
final LoadQueryInfluencers loadQueryInfluencers = session.getLoadQueryInfluencers();
LoadQueryInfluencers loadQueryInfluencers,
SessionFactoryImplementor sessionFactory) {
if ( getLoadable().isAffectedByEnabledFilters( loadQueryInfluencers ) ) {
// special case of not-cacheable based on enabled filters effecting this load.
//
@ -68,7 +74,7 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
// properly restrict the SQL/JDBC results. For this reason it has higher
// precedence than even "internal" fetch profiles.
nonReusablePlansGenerated.incrementAndGet();
return createLoadPlan( lockOptions, loadQueryInfluencers, session.getFactory() );
return createLoadPlan( lockOptions, loadQueryInfluencers, sessionFactory );
}
final CascadingFetchProfile enabledCascadingFetchProfile = loadQueryInfluencers.getEnabledCascadingFetchProfile();
@ -88,7 +94,7 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
final SingleIdLoadPlan<T> plan = createLoadPlan(
lockOptions,
loadQueryInfluencers,
session.getFactory()
sessionFactory
);
selectByInternalCascadeProfile.put( enabledCascadingFetchProfile, plan );
return plan;
@ -110,7 +116,7 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
final SingleIdLoadPlan<T> plan = createLoadPlan(
lockOptions,
loadQueryInfluencers,
session.getFactory()
sessionFactory
);
selectByLockMode.put( lockOptions.getLockMode(), plan );
@ -118,7 +124,7 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
}
nonReusablePlansGenerated.incrementAndGet();
return createLoadPlan( lockOptions, loadQueryInfluencers, session.getFactory() );
return createLoadPlan( lockOptions, loadQueryInfluencers, sessionFactory );
}
private boolean determineIfReusable(LockOptions lockOptions, LoadQueryInfluencers loadQueryInfluencers) {
@ -145,7 +151,7 @@ public class SingleIdEntityLoaderStandardImpl<T> extends SingleIdEntityLoaderSup
final List<JdbcParameter> jdbcParameters = new ArrayList<>();
final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect(
final SelectStatement sqlAst = LoaderSelectBuilder.createSelect(
getLoadable(),
// null here means to select everything
null,

View File

@ -4,11 +4,11 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.SingleIdEntityLoader;
import org.hibernate.loader.ast.spi.SingleIdEntityLoader;
import org.hibernate.metamodel.mapping.EntityMappingType;
/**

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.Iterator;
import java.util.List;
@ -14,7 +14,7 @@ import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.query.spi.QueryOptions;
@ -26,7 +26,7 @@ import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
@ -41,7 +41,7 @@ import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
*
* @author Steve Ebersole
*/
class SingleIdLoadPlan<T> implements SingleEntityLoadPlan {
public class SingleIdLoadPlan<T> implements SingleEntityLoadPlan {
private final ModelPart restrictivePart;
private final SelectStatement sqlAst;
private final List<JdbcParameter> jdbcParameters;

View File

@ -4,7 +4,7 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
@ -18,7 +18,7 @@ import org.hibernate.engine.spi.CollectionKey;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.spi.CollectionLoader;
import org.hibernate.loader.ast.spi.CollectionLoader;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.spi.QueryOptions;
@ -29,7 +29,7 @@ import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
@ -40,7 +40,7 @@ import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
*
* @author Steve Ebersole
*/
public class SingleCollectionKeyLoader implements CollectionLoader {
public class SingleKeyCollectionLoader implements CollectionLoader {
private final PluralAttributeMapping attributeMapping;
private final int keyJdbcCount;
@ -48,7 +48,7 @@ public class SingleCollectionKeyLoader implements CollectionLoader {
private final SelectStatement sqlAst;
private final List<JdbcParameter> jdbcParameters;
public SingleCollectionKeyLoader(
public SingleKeyCollectionLoader(
PluralAttributeMapping attributeMapping,
LoadQueryInfluencers influencers,
SessionFactoryImplementor sessionFactory) {
@ -57,7 +57,7 @@ public class SingleCollectionKeyLoader implements CollectionLoader {
this.keyJdbcCount = attributeMapping.getKeyDescriptor().getJdbcTypeCount( sessionFactory.getTypeConfiguration() );
this.jdbcParameters = new ArrayList<>();
this.sqlAst = MetamodelSelectBuilderProcess.createSelect(
this.sqlAst = LoaderSelectBuilder.createSelect(
attributeMapping,
null,
attributeMapping.getKeyDescriptor(),
@ -72,9 +72,21 @@ public class SingleCollectionKeyLoader implements CollectionLoader {
@Override
public PluralAttributeMapping getLoadable() {
return getAttributeMapping();
}
public PluralAttributeMapping getAttributeMapping() {
return attributeMapping;
}
public SelectStatement getSqlAst() {
return sqlAst;
}
public List<JdbcParameter> getJdbcParameters() {
return jdbcParameters;
}
@Override
public PersistentCollection load(Object key, SharedSessionContractImplementor session) {
final CollectionKey collectionKey = new CollectionKey( attributeMapping.getCollectionDescriptor(), key );

View File

@ -4,38 +4,30 @@
* 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.loader.internal;
package org.hibernate.loader.ast.internal;
import java.util.ArrayList;
import java.util.Iterator;
import org.hibernate.LockOptions;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
import org.hibernate.engine.jdbc.spi.JdbcServices;
import org.hibernate.engine.spi.CollectionKey;
import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.SubselectFetch;
import org.hibernate.loader.spi.CollectionLoader;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.loader.ast.spi.CollectionLoader;
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
import org.hibernate.query.spi.QueryOptions;
import org.hibernate.query.spi.QueryParameterBindings;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl;
import org.hibernate.sql.exec.internal.JdbcSelectExecutorStandardImpl;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBinding;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcSelect;
import org.hibernate.sql.results.internal.RowTransformerPassThruImpl;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.graph.DomainResult;
/**
* A one-time use CollectionLoader for applying a sub-select fetch
@ -61,7 +53,7 @@ public class SubSelectFetchCollectionLoader implements CollectionLoader {
jdbcParameters = new ArrayList<>();
sqlAst = MetamodelSelectBuilderProcess.createSubSelectFetchSelect(
sqlAst = LoaderSelectBuilder.createSubSelectFetchSelect(
attributeMapping,
subselect,
null,

View File

@ -0,0 +1,13 @@
/*
* 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
*/
/**
* Dedicated package for SQL AST based loaders.
*
* todo (6.0) : decide if we want this as `o.h.loader.ast` or just `o.h.loader` after legacy LoadPlan, etc have been removed
*/
package org.hibernate.loader.ast;

View File

@ -1,10 +1,10 @@
/*
* 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>.
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.persister.entity.Loadable;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.internal.util.StringHelper;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.collection.spi.PersistentCollection;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import java.util.function.Consumer;
import java.util.function.Supplier;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
/**
* Common contract for all value-mapping loaders.

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import java.util.List;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -4,7 +4,7 @@
* 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.loader.spi;
package org.hibernate.loader.ast.spi;
import org.hibernate.LockOptions;
import org.hibernate.engine.spi.SharedSessionContractImplementor;

View File

@ -26,7 +26,7 @@ import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.loader.JoinWalker;
import org.hibernate.loader.Loader;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.type.Type;

View File

@ -31,7 +31,7 @@ import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.loader.CollectionAliases;
import org.hibernate.loader.EntityAliases;
import org.hibernate.loader.Loader;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.param.ParameterBinder;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;

View File

@ -37,7 +37,7 @@ import org.hibernate.event.spi.LoadEventListener;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.persister.entity.MultiLoadOptions;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.pretty.MessageHelper;

View File

@ -37,7 +37,7 @@ import org.hibernate.loader.plan.spi.EntityIdentifierDescription;
import org.hibernate.loader.plan.spi.EntityReference;
import org.hibernate.loader.plan.spi.Fetch;
import org.hibernate.loader.plan.spi.FetchSource;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.persister.entity.Loadable;
import org.jboss.logging.Logger;

View File

@ -26,7 +26,7 @@ import org.hibernate.loader.plan.exec.query.spi.NamedParameterContext;
import org.hibernate.loader.plan.exec.spi.AliasResolutionContext;
import org.hibernate.loader.plan.spi.CollectionReturn;
import org.hibernate.loader.plan.spi.LoadPlan;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.transform.ResultTransformer;

View File

@ -13,7 +13,7 @@ import java.util.List;
import org.hibernate.engine.spi.QueryParameters;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.loader.plan.exec.query.spi.NamedParameterContext;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
import org.hibernate.transform.ResultTransformer;
/**

View File

@ -11,7 +11,7 @@ import java.sql.SQLException;
import java.util.List;
import org.hibernate.loader.plan.exec.process.internal.ResultSetProcessingContextImpl;
import org.hibernate.loader.spi.AfterLoadAction;
import org.hibernate.loader.ast.spi.AfterLoadAction;
/**
* @author Steve Ebersole

View File

@ -7,7 +7,7 @@
package org.hibernate.metamodel.mapping;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.Fetchable;
/**
* @author Steve Ebersole

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.Fetchable;
/**
* @author Steve Ebersole

View File

@ -29,10 +29,10 @@ import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.composite.CompositeResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableResultImpl;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.type.BasicType;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
@ -186,7 +186,7 @@ public class EmbeddableMappingType implements ManagedMappingType {
TableGroup tableGroup,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeResult<>(
return new EmbeddableResultImpl<>(
navigablePath,
valueMapping,
resultVariable,

View File

@ -14,8 +14,8 @@ import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.FetchableContainer;
/**
* @author Steve Ebersole

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.Fetchable;
/**
* Commonality between `many-to-one`, `one-to-one` and `any`, as well as entity-valued collection elements and map-keys

View File

@ -14,7 +14,7 @@ import java.util.function.Supplier;
import org.hibernate.LockMode;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
@ -26,8 +26,8 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.spi.DomainResultAssembler;
import org.hibernate.sql.results.spi.RowProcessingState;
import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;

View File

@ -12,9 +12,9 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchableContainer;
import org.hibernate.type.spi.TypeConfiguration;
/**

View File

@ -13,8 +13,8 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
/**
* @author Steve Ebersole
@ -51,8 +51,12 @@ public interface ForeignKeyDescriptor extends VirtualModelPart {
visitReferringColumns( consumer );
}
String getReferringTableExpression();
void visitReferringColumns(ColumnConsumer consumer);
String getTargetTableExpression();
void visitTargetColumns(ColumnConsumer consumer);
void visitColumnMappings(FkColumnMappingConsumer consumer);

View File

@ -9,8 +9,7 @@ package org.hibernate.metamodel.mapping;
import java.util.Collection;
import java.util.function.Consumer;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.hibernate.sql.results.graph.FetchableContainer;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**

View File

@ -12,8 +12,8 @@ import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -8,11 +8,11 @@ package org.hibernate.metamodel.mapping;
import java.util.function.Consumer;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.FetchableContainer;
/**
* @author Steve Ebersole

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.Fetchable;
/**
* @author Steve Ebersole

View File

@ -18,12 +18,12 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.basic.BasicFetch;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicFetch;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.BasicType;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -23,13 +23,13 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.SqlResultsLogger;
import org.hibernate.sql.results.internal.domain.basic.BasicFetch;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.ResultsLogger;
import org.hibernate.sql.results.graph.basic.BasicFetch;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.BasicType;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
@ -165,7 +165,7 @@ public class BasicValuedCollectionPart implements CollectionPart, BasicValuedMod
LockMode lockMode,
String resultVariable,
DomainResultCreationState creationState) {
SqlResultsLogger.INSTANCE.debugf(
ResultsLogger.INSTANCE.debugf(
"Generating Fetch for collection-part : `%s` -> `%s`",
collectionDescriptor.getRole(),
nature.getName()

View File

@ -28,12 +28,12 @@ import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.results.internal.domain.basic.BasicFetch;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicFetch;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration;

View File

@ -23,12 +23,12 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.basic.BasicFetch;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicFetch;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.BasicType;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;

View File

@ -16,9 +16,16 @@ import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
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.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ManagedMappingType;
@ -44,13 +51,6 @@ 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.TableReferenceCollector;
import org.hibernate.sql.results.internal.domain.composite.CompositeFetch;
import org.hibernate.sql.results.internal.domain.composite.CompositeResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.type.spi.TypeConfiguration;
/**
@ -58,7 +58,7 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public class EmbeddedAttributeMapping
extends AbstractSingularAttributeMapping
implements EmbeddableValuedModelPart, Fetchable {
implements EmbeddableValuedFetchable, Fetchable {
private final String tableExpression;
private final String[] attrColumnNames;
@ -140,7 +140,7 @@ public class EmbeddedAttributeMapping
TableGroup tableGroup,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeResult<>(
return new EmbeddableResultImpl<>(
navigablePath,
this,
resultVariable,
@ -166,7 +166,7 @@ public class EmbeddedAttributeMapping
LockMode lockMode,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeFetch(
return new EmbeddableFetchImpl(
fetchablePath,
this,
fetchParent,

View File

@ -13,36 +13,36 @@ import org.hibernate.LockMode;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming;
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.embeddable.EmbeddableValuedFetchable;
import org.hibernate.sql.results.graph.embeddable.internal.EmbeddableFetchImpl;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.ast.JoinType;
import org.hibernate.sql.ast.spi.SqlAliasBase;
import org.hibernate.sql.ast.spi.SqlAliasBaseGenerator;
import org.hibernate.sql.ast.spi.SqlAstCreationContext;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.spi.SqlExpressionResolver;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.results.internal.domain.composite.CompositeFetch;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* @author Steve Ebersole
*/
public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedModelPart {
public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedFetchable {
private final CollectionPersister collectionDescriptor;
private final Nature nature;
private final EmbeddableMappingType embeddableMappingType;
@ -120,7 +120,7 @@ public class EmbeddedCollectionPart implements CollectionPart, EmbeddableValuedM
LockMode lockMode,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeFetch(
return new EmbeddableFetchImpl(
fetchablePath,
this,
fetchParent,

View File

@ -15,12 +15,12 @@ import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
import org.hibernate.metamodel.mapping.ColumnConsumer;
import org.hibernate.metamodel.mapping.EmbeddableMappingType;
import org.hibernate.metamodel.mapping.EmbeddedIdentifierMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.metamodel.mapping.ManagedMappingType;
import org.hibernate.metamodel.mapping.MappingType;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
@ -44,12 +44,12 @@ 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.TableReferenceCollector;
import org.hibernate.sql.results.internal.domain.composite.CompositeFetch;
import org.hibernate.sql.results.internal.domain.composite.CompositeResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
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.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetch;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
@ -57,7 +57,7 @@ import org.hibernate.type.spi.TypeConfiguration;
* @author Andrea Boriero
*/
public class EmbeddedIdentifierMappingImpl
implements EmbeddedIdentifierMapping {
implements EmbeddedIdentifierMapping, EmbeddableValuedFetchable {
private final String name;
private final MappingType type;
private final StateArrayContributorMetadataAccess attributeMetadataAccess;
@ -142,7 +142,7 @@ public class EmbeddedIdentifierMappingImpl
TableGroup tableGroup,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeResult<>(
return new EmbeddableResultImpl<>(
navigablePath,
this,
resultVariable,
@ -281,7 +281,7 @@ public class EmbeddedIdentifierMappingImpl
LockMode lockMode,
String resultVariable,
DomainResultCreationState creationState) {
return new CompositeFetch(
return new EmbeddableFetchImpl(
fetchablePath,
this,
fetchParent,

View File

@ -10,25 +10,25 @@ import org.hibernate.LockMode;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.engine.FetchStrategy;
import org.hibernate.engine.FetchTiming;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.EntityCollectionPartTableGroup;
import org.hibernate.sql.results.graph.entity.EntityFetch;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl;
import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityAssociationMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.query.NavigablePath;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.internal.domain.collection.EntityCollectionPartTableGroup;
import org.hibernate.sql.results.internal.domain.entity.EntityFetch;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**
* @author Steve Ebersole
*/
public class EntityCollectionPart implements CollectionPart, EntityAssociationMapping, EntityValuedModelPart {
public class EntityCollectionPart implements CollectionPart, EntityAssociationMapping, EntityValuedFetchable {
private final Nature nature;
private final EntityMappingType entityMappingType;
@ -95,7 +95,7 @@ public class EntityCollectionPart implements CollectionPart, EntityAssociationMa
}
@Override
public Fetch generateFetch(
public EntityFetch generateFetch(
FetchParent fetchParent,
NavigablePath fetchablePath,
FetchTiming fetchTiming,
@ -112,7 +112,7 @@ public class EntityCollectionPart implements CollectionPart, EntityAssociationMa
return new EntityCollectionPartTableGroup( fetchablePath, collectionTableGroup, this );
}
);
return new EntityFetch( fetchParent, this, lockMode, selected, fetchablePath, creationState );
return new EntityFetchJoinedImpl( fetchParent, this, lockMode, selected, fetchablePath, creationState );
}
@Override

View File

@ -12,7 +12,7 @@ import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.BasicType;
/**

View File

@ -14,7 +14,7 @@ import org.hibernate.sql.ast.spi.SqlSelection;
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.BasicType;
/**

View File

@ -77,12 +77,12 @@ import org.hibernate.sql.ast.tree.expression.ColumnReference;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.results.internal.domain.basic.BasicFetch;
import org.hibernate.sql.results.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicFetch;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.AssociationType;
import org.hibernate.type.BasicType;
import org.hibernate.type.CompositeType;
@ -197,7 +197,8 @@ public class MappingModelCreationHelper {
return new BasicResult(
sqlSelection.getValuesArrayPosition(),
resultVariable,
entityPersister.getIdentifierMapping().getMappedTypeDescriptor().getMappedJavaTypeDescriptor()
entityPersister.getIdentifierMapping().getMappedTypeDescriptor().getMappedJavaTypeDescriptor(),
navigablePath
);
}

View File

@ -41,13 +41,13 @@ import org.hibernate.sql.ast.tree.from.TableGroupBuilder;
import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.internal.domain.collection.CollectionDomainResult;
import org.hibernate.sql.results.internal.domain.collection.DelayedCollectionFetch;
import org.hibernate.sql.results.internal.domain.collection.EagerCollectionFetch;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult;
import org.hibernate.sql.results.graph.collection.internal.DelayedCollectionFetch;
import org.hibernate.sql.results.graph.collection.internal.EagerCollectionFetch;
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;
/**
* @author Steve Ebersole

View File

@ -34,11 +34,11 @@ import org.hibernate.sql.ast.tree.from.TableReference;
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.internal.domain.basic.BasicResult;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicResult;
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.type.ForeignKeyDirection;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
import org.hibernate.type.spi.TypeConfiguration;
@ -258,11 +258,21 @@ public class SimpleForeignKeyDescriptor implements ForeignKeyDescriptor, BasicVa
return jdbcMapping.getJavaTypeDescriptor();
}
@Override
public String getReferringTableExpression() {
return keyColumnContainingTable;
}
@Override
public void visitReferringColumns(ColumnConsumer consumer) {
consumer.accept( keyColumnContainingTable, keyColumnExpression, jdbcMapping );
}
@Override
public String getTargetTableExpression() {
return targetColumnContainingTable;
}
@Override
public void visitTargetColumns(ColumnConsumer consumer) {
consumer.accept( targetColumnContainingTable, targetColumnExpression, jdbcMapping );

View File

@ -12,7 +12,6 @@ import org.hibernate.engine.FetchTiming;
import org.hibernate.mapping.ToOne;
import org.hibernate.metamodel.mapping.EntityAssociationMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
import org.hibernate.metamodel.mapping.ManagedMappingType;
import org.hibernate.metamodel.mapping.ModelPart;
@ -35,20 +34,20 @@ import org.hibernate.sql.ast.tree.from.TableGroupJoin;
import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer;
import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.internal.domain.entity.DelayedEntityFetchImpl;
import org.hibernate.sql.results.internal.domain.entity.EntityFetch;
import org.hibernate.sql.results.internal.domain.entity.SelectEntityFetchImpl;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetch;
import org.hibernate.sql.results.spi.FetchParent;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.entity.EntityFetch;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
import org.hibernate.sql.results.graph.entity.internal.EntityFetchDelayedImpl;
import org.hibernate.sql.results.graph.entity.internal.EntityFetchJoinedImpl;
import org.hibernate.sql.results.graph.entity.internal.EntityFetchSelectImpl;
/**
* @author Steve Ebersole
*/
public class SingularAssociationAttributeMapping extends AbstractSingularAttributeMapping
implements EntityValuedModelPart, EntityAssociationMapping, TableGroupJoinProducer {
implements EntityValuedFetchable, EntityAssociationMapping, TableGroupJoinProducer {
private final String sqlAliasStem;
private final boolean isNullable;
private final boolean referringPrimaryKey;
@ -106,7 +105,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
}
@Override
public Fetch generateFetch(
public EntityFetch generateFetch(
FetchParent fetchParent,
NavigablePath fetchablePath,
FetchTiming fetchTiming,
@ -115,12 +114,12 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
String resultVariable,
DomainResultCreationState creationState) {
final SqlAstCreationState sqlAstCreationState = creationState.getSqlAstCreationState();
final TableGroup lhsTableGroup = sqlAstCreationState.getFromClauseAccess()
.getTableGroup( fetchParent.getNavigablePath() );
final TableGroup lhsTableGroup = sqlAstCreationState.getFromClauseAccess().getTableGroup(
fetchParent.getNavigablePath()
);
if ( fetchTiming == FetchTiming.IMMEDIATE && selected ) {
if ( sqlAstCreationState.getFromClauseAccess().findTableGroup( fetchablePath ) == null ) {
// todo (6.0) : verify the JoinType is correct
JoinType joinType;
if ( isNullable ) {
joinType = JoinType.LEFT;
@ -147,7 +146,7 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
);
}
return new EntityFetch(
return new EntityFetchJoinedImpl(
fetchParent,
this,
lockMode,
@ -157,33 +156,36 @@ public class SingularAssociationAttributeMapping extends AbstractSingularAttribu
);
}
final DomainResult result;
final DomainResult keyResult;
if ( referringPrimaryKey ) {
result = foreignKeyDescriptor.createDomainResult( fetchablePath, lhsTableGroup, creationState );
keyResult = foreignKeyDescriptor.createDomainResult( fetchablePath, lhsTableGroup, creationState );
}
else {
result = ( (EntityPersister) getDeclaringType() ).getIdentifierMapping()
keyResult = ( (EntityPersister) getDeclaringType() ).getIdentifierMapping()
.createDomainResult( fetchablePath, lhsTableGroup, null, creationState );
}
if ( fetchTiming == FetchTiming.IMMEDIATE && !selected ) {
return new SelectEntityFetchImpl(
assert !selected;
if ( fetchTiming == FetchTiming.IMMEDIATE ) {
return new EntityFetchSelectImpl(
fetchParent,
this,
lockMode,
isNullable,
fetchablePath,
result
keyResult,
creationState
);
}
return new DelayedEntityFetchImpl(
return new EntityFetchDelayedImpl(
fetchParent,
this,
lockMode,
isNullable,
fetchablePath,
result
keyResult
);
}

View File

@ -168,7 +168,7 @@ public class JpaMetamodelImpl implements JpaMetamodel {
@Override
public <X> ManagedDomainType<X> managedType(Class<X> cls) {
ManagedType<?> type = jpaEntityTypeMap.get( cls );
ManagedType<?> type = jpaEntityTypeMap.get( cls.getName() );
if ( type == null ) {
type = jpaMappedSuperclassTypeMap.get( cls );
}

View File

@ -59,10 +59,10 @@ import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jdbc.Expectation;
import org.hibernate.jdbc.Expectations;
import org.hibernate.loader.collection.CollectionInitializer;
import org.hibernate.loader.internal.BatchCollectionKeyLoader;
import org.hibernate.loader.internal.SingleCollectionKeyLoader;
import org.hibernate.loader.internal.SubSelectFetchCollectionLoader;
import org.hibernate.loader.spi.CollectionLoader;
import org.hibernate.loader.ast.internal.BatchKeyCollectionLoader;
import org.hibernate.loader.ast.internal.SingleKeyCollectionLoader;
import org.hibernate.loader.ast.internal.SubSelectFetchCollectionLoader;
import org.hibernate.loader.ast.spi.CollectionLoader;
import org.hibernate.mapping.BasicValue;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Column;
@ -113,7 +113,7 @@ import org.hibernate.sql.ast.tree.from.TableReferenceCollector;
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.spi.DomainResult;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.BasicType;
@ -857,10 +857,10 @@ public abstract class AbstractCollectionPersister
protected CollectionLoader createCollectionLoader(LoadQueryInfluencers loadQueryInfluencers) {
final int batchSize = getBatchSize();
if ( batchSize > 1 ) {
return new BatchCollectionKeyLoader( attributeMapping, batchSize, loadQueryInfluencers, getFactory() );
return new BatchKeyCollectionLoader( attributeMapping, batchSize, loadQueryInfluencers, getFactory() );
}
return new SingleCollectionKeyLoader( attributeMapping, loadQueryInfluencers, getFactory() );
return new SingleKeyCollectionLoader( attributeMapping, loadQueryInfluencers, getFactory() );
}

View File

@ -112,16 +112,16 @@ import org.hibernate.loader.entity.BatchingEntityLoaderBuilder;
import org.hibernate.loader.entity.CascadeEntityLoader;
import org.hibernate.loader.entity.EntityLoader;
import org.hibernate.loader.entity.UniqueEntityLoader;
import org.hibernate.loader.internal.MultiIdEntityLoaderStandardImpl;
import org.hibernate.loader.internal.NaturalIdLoaderStandardImpl;
import org.hibernate.loader.internal.Preparable;
import org.hibernate.loader.internal.SingleIdEntityLoaderDynamicBatch;
import org.hibernate.loader.internal.SingleIdEntityLoaderProvidedQueryImpl;
import org.hibernate.loader.internal.SingleIdEntityLoaderStandardImpl;
import org.hibernate.loader.spi.Loader;
import org.hibernate.loader.spi.MultiIdEntityLoader;
import org.hibernate.loader.spi.NaturalIdLoader;
import org.hibernate.loader.spi.SingleIdEntityLoader;
import org.hibernate.loader.ast.internal.MultiIdEntityLoaderStandardImpl;
import org.hibernate.loader.ast.internal.NaturalIdLoaderStandardImpl;
import org.hibernate.loader.ast.internal.Preparable;
import org.hibernate.loader.ast.internal.SingleIdEntityLoaderDynamicBatch;
import org.hibernate.loader.ast.internal.SingleIdEntityLoaderProvidedQueryImpl;
import org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl;
import org.hibernate.loader.ast.spi.Loader;
import org.hibernate.loader.ast.spi.MultiIdEntityLoader;
import org.hibernate.loader.ast.spi.NaturalIdLoader;
import org.hibernate.loader.ast.spi.SingleIdEntityLoader;
import org.hibernate.mapping.Column;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Formula;
@ -194,11 +194,11 @@ import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate;
import org.hibernate.sql.ast.tree.predicate.Junction;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.internal.domain.entity.EntityResultImpl;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.spi.Fetchable;
import org.hibernate.sql.results.spi.FetchableContainer;
import org.hibernate.sql.results.graph.entity.internal.EntityResultImpl;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.FetchableContainer;
import org.hibernate.stat.spi.StatisticsImplementor;
import org.hibernate.tuple.GenerationTiming;
import org.hibernate.tuple.InDatabaseValueGenerationStrategy;

View File

@ -29,7 +29,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.ValueInclusion;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.loader.spi.Loadable;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;

View File

@ -72,9 +72,9 @@ import org.hibernate.sql.ast.tree.from.TableReference;
import org.hibernate.sql.ast.tree.from.TableReferenceJoin;
import org.hibernate.sql.ast.tree.predicate.NullnessPredicate;
import org.hibernate.sql.ast.tree.predicate.Predicate;
import org.hibernate.sql.results.internal.domain.entity.JoinedSubclassResultImpl;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.entity.internal.EntityResultJoinedSubclassImpl;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.BasicType;
import org.hibernate.type.DiscriminatorType;
import org.hibernate.type.StandardBasicTypes;
@ -1169,7 +1169,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
DomainResultCreationState creationState) {
if ( hasSubclasses() ) {
//noinspection unchecked
return new JoinedSubclassResultImpl( navigablePath, this, resultVariable, creationState );
return new EntityResultJoinedSubclassImpl( navigablePath, this, resultVariable, creationState );
}
else {
return super.createDomainResult( navigablePath, tableGroup, resultVariable, creationState );

View File

@ -164,7 +164,14 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
throw (HibernateException) target;
}
else {
throw new MappingException( "Could not instantiate collection persister " + persisterClass.getName(), target );
throw new MappingException(
String.format(
"Could not instantiate collection persister implementor `%s` for collection-role `%s`",
persisterClass.getName(),
collectionBinding.getRole()
),
target
);
}
}
catch (Exception e) {

View File

@ -8,8 +8,8 @@ package org.hibernate.procedure.internal;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.query.sqm.SqmExpressable;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.query.sqm.sql.internal.DomainResultProducer;
/**

View File

@ -6,8 +6,8 @@
*/
package org.hibernate.query.spi;
import org.hibernate.sql.results.spi.DomainResult;
import org.hibernate.sql.results.spi.DomainResultCreationState;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.type.descriptor.java.JavaTypeDescriptor;
/**

View File

@ -81,7 +81,7 @@ import org.hibernate.query.sql.spi.ParameterInterpretation;
import org.hibernate.query.sql.spi.SelectInterpretationsKey;
import org.hibernate.sql.exec.spi.Callback;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.results.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.spi.RowTransformer;
import org.hibernate.transform.ResultTransformer;

View File

@ -11,19 +11,11 @@ import java.util.Set;
import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.ScrollMode;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.model.domain.AllowableParameterType;
import org.hibernate.query.spi.QueryParameterBinding;
import org.hibernate.query.spi.QueryParameterImplementor;
import org.hibernate.query.spi.ScrollableResultsImplementor;
import org.hibernate.query.sql.spi.NativeSelectQueryPlan;
import org.hibernate.sql.ast.Clause;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameterBinder;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
import org.hibernate.sql.exec.spi.JdbcSelectExecutor;
import org.hibernate.sql.results.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.spi.RowTransformer;
/**

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Set;
import org.hibernate.query.spi.QueryParameterImplementor;
import org.hibernate.sql.results.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.spi.RowTransformer;
/**

View File

@ -11,7 +11,7 @@ import java.util.Objects;
import org.hibernate.query.ResultListTransformer;
import org.hibernate.query.TupleTransformer;
import org.hibernate.query.spi.QueryInterpretationCache;
import org.hibernate.sql.results.spi.JdbcValuesMappingProducer;
import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer;
/**
* @author Steve Ebersole

View File

@ -34,7 +34,7 @@ import org.hibernate.query.sqm.tree.select.SqmSelection;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.spi.FromClauseAccess;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcSelect;
import org.hibernate.sql.results.internal.RowTransformerJpaTupleImpl;

View File

@ -29,12 +29,11 @@ import org.hibernate.sql.ast.SqlAstDeleteTranslator;
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.tree.expression.Expression;
import org.hibernate.sql.ast.tree.from.MutatingTableReferenceGroupWrapper;
import org.hibernate.sql.ast.tree.from.StandardTableGroup;
import org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate;
import org.hibernate.sql.ast.tree.select.QuerySpec;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcDelete;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.results.internal.SqlSelectionImpl;

View File

@ -24,7 +24,7 @@ import org.hibernate.sql.ast.SqlAstTranslatorFactory;
import org.hibernate.sql.ast.SqlAstUpdateTranslator;
import org.hibernate.sql.ast.spi.FromClauseAccess;
import org.hibernate.sql.exec.spi.ExecutionContext;
import org.hibernate.sql.exec.spi.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.exec.spi.JdbcParameterBindings;
import org.hibernate.sql.exec.spi.JdbcUpdate;

Some files were not shown because too many files have changed in this diff Show More