diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractBagSemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractBagSemantics.java index 840a3791be..1d380234e6 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractBagSemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractBagSemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractMapSemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractMapSemantics.java index c4899f8280..588d74d51b 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractMapSemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractMapSemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractSetSemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractSetSemantics.java index 85b6e7e9c4..d32cff6979 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractSetSemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/AbstractSetSemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentArrayHolder.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentArrayHolder.java index 14e58537a9..e7627967c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentArrayHolder.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentArrayHolder.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentBag.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentBag.java index 8b820d77f8..6802dda9ff 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentBag.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentBag.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentIdentifierBag.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentIdentifierBag.java index 7ae06b991f..cf63bdb8ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentIdentifierBag.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentIdentifierBag.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentList.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentList.java index 6dcf1c6bbc..af4fe8735d 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentList.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentList.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java index 9ff7cee211..c2b4de3760 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentMap.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentSet.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentSet.java index 0cf9a5d204..4635f833f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentSet.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/PersistentSet.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardArraySemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardArraySemantics.java index 7c7fe50ba6..a393562781 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardArraySemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardArraySemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardListSemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardListSemantics.java index 903afbddd4..fef5740322 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardListSemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/internal/StandardListSemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionInitializerProducer.java index e78c9ef3f5..2184ab9e93 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionInitializerProducer.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionSemantics.java b/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionSemantics.java index 551783b2f9..d27e743cc8 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionSemantics.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/spi/CollectionSemantics.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/collection/spi/PersistentCollection.java b/hibernate-core/src/main/java/org/hibernate/collection/spi/PersistentCollection.java index bfb788b742..99c4970f72 100644 --- a/hibernate-core/src/main/java/org/hibernate/collection/spi/PersistentCollection.java +++ b/hibernate-core/src/main/java/org/hibernate/collection/spi/PersistentCollection.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java index e5e5a1215c..c21a918207 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/LoadQueryInfluencers.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java index a49b0e2176..07eceff931 100755 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/SubselectFetch.java @@ -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 loadingJdbcParameters; private final JdbcParameterBindings loadingJdbcParameterBindings; private final Set resultingEntityKeys; @@ -28,11 +30,13 @@ public class SubselectFetch { public SubselectFetch( EntityValuedModelPart entityModelPart, QuerySpec loadingSqlAst, + TableGroup ownerTableGroup, List loadingJdbcParameters, JdbcParameterBindings loadingJdbcParameterBindings, Set 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 getLoadingJdbcParameters() { return loadingJdbcParameters; } diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java index 89b8a1b239..5a74f7e6d6 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultMergeEventListener.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultRefreshEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultRefreshEventListener.java index 54ec1f5eb6..adea24dbfc 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultRefreshEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/DefaultRefreshEventListener.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/internal/AbstractScrollableResults.java b/hibernate-core/src/main/java/org/hibernate/internal/AbstractScrollableResults.java index 8859a5688d..a1479bbe00 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/AbstractScrollableResults.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/AbstractScrollableResults.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java index de7abd9660..98a3a0a4db 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/FetchingScrollableResultsImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/ScrollableResultsImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/ScrollableResultsImpl.java index bfd45d542d..d7a1e1485a 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/ScrollableResultsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/ScrollableResultsImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/SingletonStack.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/SingletonStack.java index 3e59bc5a37..a113816338 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/SingletonStack.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/SingletonStack.java @@ -53,6 +53,11 @@ public class SingletonStack implements Stack { public void clear() { } + @Override + public void visitRootFirst(Consumer action) { + action.accept( instance ); + } + @Override public void visitCurrentFirst(Consumer action) { action.accept( instance ); diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/Stack.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/Stack.java index 240d48ab22..8bc2c95851 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/Stack.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/Stack.java @@ -52,6 +52,11 @@ public interface Stack { */ void clear(); + /** + * Visit all elements in the stack, starting with the root and working "forward" + */ + void visitRootFirst(Consumer action); + /** * Visit all elements in the stack, starting with the current and working back */ diff --git a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/StandardStack.java b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/StandardStack.java index 4fc7b573fa..3786b28d8e 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/util/collections/StandardStack.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/util/collections/StandardStack.java @@ -103,6 +103,19 @@ public class StandardStack implements Stack { } } + @Override + public void visitRootFirst(Consumer 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 action) { if ( current != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index e805b4671e..0229868697 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/BatchCollectionKeyLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/BatchKeyCollectionLoader.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/BatchCollectionKeyLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/BatchKeyCollectionLoader.java index bc3c36d6c8..49bb9bc6ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/BatchCollectionKeyLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/BatchKeyCollectionLoader.java @@ -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 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 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, diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/DatabaseSnapshotExecutor.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/DatabaseSnapshotExecutor.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java index 937a507c91..e3fa9be67f 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/DatabaseSnapshotExecutor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/DatabaseSnapshotExecutor.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/LoadPlan.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoadPlan.java similarity index 67% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/LoadPlan.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoadPlan.java index 1655d4ebd8..46b7283dbb 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/LoadPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoadPlan.java @@ -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(); } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/MetamodelSelectBuilderProcess.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/MetamodelSelectBuilderProcess.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java index ea22cd7bd6..ddd03c9179 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/MetamodelSelectBuilderProcess.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSelectBuilder.java @@ -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 partsToSelect, @@ -72,7 +90,7 @@ public class MetamodelSelectBuilderProcess { LockOptions lockOptions, Consumer 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 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 jdbcParameterConsumer; - private MetamodelSelectBuilderProcess( + private LoaderSelectBuilder( SqlAstCreationContext creationContext, Loadable loadable, List 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 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 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 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; } } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/LoaderSqlAstCreationState.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSqlAstCreationState.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/LoaderSqlAstCreationState.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSqlAstCreationState.java index 0cee77dc0d..e4169645b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/LoaderSqlAstCreationState.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/LoaderSqlAstCreationState.java @@ -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> 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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/MultiIdEntityLoaderStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderStandardImpl.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/MultiIdEntityLoaderStandardImpl.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderStandardImpl.java index 97c98ce8c1..07c552268b 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/MultiIdEntityLoaderStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/MultiIdEntityLoaderStandardImpl.java @@ -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 implements MultiIdEntityLoader 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 implements MultiIdEntityLoader implements MultiIdEntityLoader() diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/NaturalIdLoaderStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/NaturalIdLoaderStandardImpl.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/NaturalIdLoaderStandardImpl.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/NaturalIdLoaderStandardImpl.java index 57e2d7c3ff..a5c3df5bcd 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/NaturalIdLoaderStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/NaturalIdLoaderStandardImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/Preparable.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/Preparable.java new file mode 100644 index 0000000000..f21079dc37 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/Preparable.java @@ -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(); +} diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleEntityLoadPlan.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleEntityLoadPlan.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleEntityLoadPlan.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleEntityLoadPlan.java index 167049c2c0..09f09f7b23 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleEntityLoadPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleEntityLoadPlan.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderDynamicBatch.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderDynamicBatch.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderDynamicBatch.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderDynamicBatch.java index 9c60f4fe7b..4b938a69dd 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderDynamicBatch.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderDynamicBatch.java @@ -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 extends SingleIdEntityLoaderSup final List jdbcParameters = new ArrayList<>(); - final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect( + final SelectStatement sqlAst = LoaderSelectBuilder.createSelect( getLoadable(), // null here means to select everything null, diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderProvidedQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderProvidedQueryImpl.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java index c25dd80a35..bc5224a6f8 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderProvidedQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderProvidedQueryImpl.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderStandardImpl.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderStandardImpl.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderStandardImpl.java index b72c9244d3..1f3c58b0f4 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderStandardImpl.java @@ -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 extends SingleIdEntityLoaderSup @Override public T load(Object key, LockOptions lockOptions, SharedSessionContractImplementor session) { - final SingleIdLoadPlan loadPlan = resolveLoadPlan( lockOptions, session ); + final SingleIdLoadPlan loadPlan = resolveLoadPlan( + lockOptions, + session.getLoadQueryInfluencers(), + session.getFactory() + ); return loadPlan.load( key, lockOptions, session ); } - private SingleIdLoadPlan resolveLoadPlan( + @Internal + public SingleIdLoadPlan 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 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 extends SingleIdEntityLoaderSup final SingleIdLoadPlan plan = createLoadPlan( lockOptions, loadQueryInfluencers, - session.getFactory() + sessionFactory ); selectByInternalCascadeProfile.put( enabledCascadingFetchProfile, plan ); return plan; @@ -110,7 +116,7 @@ public class SingleIdEntityLoaderStandardImpl extends SingleIdEntityLoaderSup final SingleIdLoadPlan plan = createLoadPlan( lockOptions, loadQueryInfluencers, - session.getFactory() + sessionFactory ); selectByLockMode.put( lockOptions.getLockMode(), plan ); @@ -118,7 +124,7 @@ public class SingleIdEntityLoaderStandardImpl 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 extends SingleIdEntityLoaderSup final List jdbcParameters = new ArrayList<>(); - final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect( + final SelectStatement sqlAst = LoaderSelectBuilder.createSelect( getLoadable(), // null here means to select everything null, diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderSupport.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderSupport.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderSupport.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderSupport.java index 376363e9e7..07de28d074 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdEntityLoaderSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdEntityLoaderSupport.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdLoadPlan.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdLoadPlan.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdLoadPlan.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdLoadPlan.java index 90a45fe03e..a844d2606f 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleIdLoadPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleIdLoadPlan.java @@ -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 implements SingleEntityLoadPlan { +public class SingleIdLoadPlan implements SingleEntityLoadPlan { private final ModelPart restrictivePart; private final SelectStatement sqlAst; private final List jdbcParameters; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleCollectionKeyLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleKeyCollectionLoader.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SingleCollectionKeyLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleKeyCollectionLoader.java index 2afaf65e6d..38b6d90902 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SingleCollectionKeyLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SingleKeyCollectionLoader.java @@ -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 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 getJdbcParameters() { + return jdbcParameters; + } + @Override public PersistentCollection load(Object key, SharedSessionContractImplementor session) { final CollectionKey collectionKey = new CollectionKey( attributeMapping.getCollectionDescriptor(), key ); diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/SubSelectFetchCollectionLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SubSelectFetchCollectionLoader.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/SubSelectFetchCollectionLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SubSelectFetchCollectionLoader.java index 95c4aeba8e..2991637594 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/SubSelectFetchCollectionLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/internal/SubSelectFetchCollectionLoader.java @@ -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, diff --git a/hibernate-core/src/main/java/org/hibernate/loader/ast/package-info.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/package-info.java new file mode 100644 index 0000000000..0d884e77e3 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/package-info.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/AfterLoadAction.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/AfterLoadAction.java similarity index 74% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/AfterLoadAction.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/AfterLoadAction.java index 1d8acf2690..b112b299ff 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/AfterLoadAction.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/AfterLoadAction.java @@ -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 . + * 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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/CascadingFetchProfile.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CascadingFetchProfile.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/CascadingFetchProfile.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CascadingFetchProfile.java index ec5aff5b31..ed7bba6b27 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/CascadingFetchProfile.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CascadingFetchProfile.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/CollectionLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CollectionLoader.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/CollectionLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CollectionLoader.java index 6b770e6ff4..9c85ac1c95 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/CollectionLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/CollectionLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/Loadable.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loadable.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/Loadable.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loadable.java index 1ecc9093d9..bafb05be3e 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/Loadable.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loadable.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loader.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/Loader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loader.java index 020b721d5e..bbf32a96b1 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/Loader.java @@ -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. diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/MultiIdEntityLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/MultiIdEntityLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java index c13529fe9b..e14c6a0438 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/MultiIdEntityLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/MultiIdEntityLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/NaturalIdLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/NaturalIdLoader.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/NaturalIdLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/NaturalIdLoader.java index 73b073ae88..f338951e0c 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/NaturalIdLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/NaturalIdLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleEntityLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleEntityLoader.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/SingleEntityLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleEntityLoader.java index 60fc500135..0a25c46eb2 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleEntityLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleEntityLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleIdEntityLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleIdEntityLoader.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/SingleIdEntityLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleIdEntityLoader.java index c0810c0e1b..1f1823dd4d 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleIdEntityLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleIdEntityLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleUniqueKeyEntityLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleUniqueKeyEntityLoader.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/loader/spi/SingleUniqueKeyEntityLoader.java rename to hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleUniqueKeyEntityLoader.java index 0d9d131358..4ee2e5003f 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/spi/SingleUniqueKeyEntityLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/ast/spi/SingleUniqueKeyEntityLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/collection/DynamicBatchingCollectionInitializerBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/collection/DynamicBatchingCollectionInitializerBuilder.java index 25e0d64674..472acf9c1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/collection/DynamicBatchingCollectionInitializerBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/collection/DynamicBatchingCollectionInitializerBuilder.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java b/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java index f03e39ace3..3743e2a417 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/custom/CustomLoader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/entity/DynamicBatchingEntityLoaderBuilder.java b/hibernate-core/src/main/java/org/hibernate/loader/entity/DynamicBatchingEntityLoaderBuilder.java index bc3426ba7f..8e09bf298c 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/entity/DynamicBatchingEntityLoaderBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/entity/DynamicBatchingEntityLoaderBuilder.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/AbstractRowReader.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/AbstractRowReader.java index c37eeee68b..d8e931b9d8 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/AbstractRowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/AbstractRowReader.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessorImpl.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessorImpl.java index ece46b1477..cf702fb206 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/internal/ResultSetProcessorImpl.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/ResultSetProcessor.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/ResultSetProcessor.java index b18219858b..42bb92a7b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/ResultSetProcessor.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/ResultSetProcessor.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/RowReader.java b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/RowReader.java index 88b7929c71..9a6e849b81 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/RowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/plan/exec/process/spi/RowReader.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java index d10aaf721b..430f86f29e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/BasicValuedModelPart.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/CollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/CollectionPart.java index f1b4ebceb8..4a07a2de86 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/CollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/CollectionPart.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java index 646766cb63..05754b5426 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableMappingType.java @@ -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, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java index e04e43b3af..0d7d372a4e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EmbeddableValuedModelPart.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityAssociationMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityAssociationMapping.java index e9d50b257e..b94e413caa 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityAssociationMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityAssociationMapping.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java index 2f7f9cc627..3e5b1a0733 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityMappingType.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityValuedModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityValuedModelPart.java index b7e8a4a748..3bf7e710c5 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityValuedModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/EntityValuedModelPart.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java index 4973f85b0d..601cf484a7 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ForeignKeyDescriptor.java @@ -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); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ManagedMappingType.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ManagedMappingType.java index 4036fde2a1..55db6b7b23 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ManagedMappingType.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ManagedMappingType.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java index d4d8478afc..24ce797bfb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/ModelPart.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/PluralAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/PluralAttributeMapping.java index 1476178222..7b894cda68 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/PluralAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/PluralAttributeMapping.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/StateArrayContributorMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/StateArrayContributorMapping.java index 35a0d33a02..10706f7b05 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/StateArrayContributorMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/StateArrayContributorMapping.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityDiscriminatorMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityDiscriminatorMapping.java index a28d64798c..ae73fca4b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityDiscriminatorMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/AbstractEntityDiscriminatorMapping.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java index a1d74829f3..c23bd13929 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedCollectionPart.java @@ -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() diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java index c35ef34fe0..1dd1e7b525 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/BasicValuedSingularAttributeMapping.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java index 7da19d7589..82de865873 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/CollectionIdentifierDescriptorImpl.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java index 5c1de3b8a6..c41ef90c8f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedAttributeMapping.java @@ -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, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java index 8078cdf883..a818188b86 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedCollectionPart.java @@ -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, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedIdentifierMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedIdentifierMappingImpl.java index 503bfc2625..beaa525579 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedIdentifierMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EmbeddedIdentifierMappingImpl.java @@ -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, diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java index c3a4555bdf..e03fa7c3a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityCollectionPart.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityDiscriminatorMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityDiscriminatorMappingImpl.java index d1b05ecee9..4b2105db98 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityDiscriminatorMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/EntityDiscriminatorMappingImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/JoinedSubclassDiscriminatorMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/JoinedSubclassDiscriminatorMappingImpl.java index 31b157ffdd..1bc32e9b5c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/JoinedSubclassDiscriminatorMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/JoinedSubclassDiscriminatorMappingImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java index c9bf126a63..e56ea5973d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/MappingModelCreationHelper.java @@ -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 ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java index 7d3aecd65c..d46220a5c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/PluralAttributeMappingImpl.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java index 944aee24ee..48654a6a2e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SimpleForeignKeyDescriptor.java @@ -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 ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingularAssociationAttributeMapping.java b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingularAssociationAttributeMapping.java index 2872440abd..688c08532b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingularAssociationAttributeMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/SingularAssociationAttributeMapping.java @@ -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 ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java index e6b7140eb6..750b47deb5 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/internal/JpaMetamodelImpl.java @@ -168,7 +168,7 @@ public class JpaMetamodelImpl implements JpaMetamodel { @Override public ManagedDomainType managedType(Class cls) { - ManagedType type = jpaEntityTypeMap.get( cls ); + ManagedType type = jpaEntityTypeMap.get( cls.getName() ); if ( type == null ) { type = jpaMappedSuperclassTypeMap.get( cls ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index bb932adf98..f05c040e23 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -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() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index e1abe70665..350f8485f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java index a280b64c81..38e1aa3507 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java index 30d8722aba..b751f04907 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/JoinedSubclassEntityPersister.java @@ -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 ); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryImpl.java index 14b94ce8c4..326719ab9e 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/internal/PersisterFactoryImpl.java @@ -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) { diff --git a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultProducer.java b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultProducer.java index 73533f08f4..403461d447 100644 --- a/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/procedure/internal/ScalarDomainResultProducer.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryResultBuilder.java b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryResultBuilder.java index 8b6acaf562..ad30288f3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryResultBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryResultBuilder.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java index 4ec8a2acd4..9b91f8c17f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeQueryImpl.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java index 1afd8a436b..a4d0e1712b 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/internal/NativeSelectQueryPlanImpl.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeSelectQueryDefinition.java b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeSelectQueryDefinition.java index 5fa400ee70..60b7b47086 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeSelectQueryDefinition.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/NativeSelectQueryDefinition.java @@ -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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/SelectInterpretationsKey.java b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/SelectInterpretationsKey.java index a92bab6966..80ec6f8e5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sql/spi/SelectInterpretationsKey.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sql/spi/SelectInterpretationsKey.java @@ -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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java index aa7783e023..3277febc87 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/ConcreteSqmSelectQueryPlan.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java index 5f5524ed99..945a69ebf8 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleDeleteQueryPlan.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java index adc467d321..7f26714281 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleUpdateQueryPlan.java @@ -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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmUtil.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmUtil.java index 822c3e5627..736f8dae8a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmUtil.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmUtil.java @@ -29,7 +29,6 @@ import org.hibernate.query.spi.QueryParameterBinding; import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.query.spi.QueryParameterImplementor; import org.hibernate.query.sqm.spi.JdbcParameterBySqmParameterAccess; -import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.query.sqm.tree.SqmDmlStatement; import org.hibernate.query.sqm.tree.SqmStatement; import org.hibernate.query.sqm.tree.expression.SqmParameter; @@ -37,7 +36,7 @@ import org.hibernate.query.sqm.tree.select.SqmSelectStatement; import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.exec.internal.JdbcParameterBindingsImpl; -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.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java index a62cd601df..e8dda1ae63 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MatchingIdSelectionHelper.java @@ -31,12 +31,12 @@ import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; 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.SqlSelectionImpl; -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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java index 7990d94493..f83efdcf88 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/MultiTableSqmMutationConverter.java @@ -39,8 +39,8 @@ import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.update.Assignable; import org.hibernate.sql.ast.tree.update.Assignment; -import org.hibernate.sql.exec.spi.JdbcParameter; -import org.hibernate.sql.results.spi.DomainResultCreationState; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * Specialized BaseSqmToSqlAstConverter implementation used during conversion diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java index 7ea8a30912..282e71c230 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/RestrictedDeleteExecutionDelegate.java @@ -27,7 +27,6 @@ import org.hibernate.metamodel.mapping.ForeignKeyDescriptor; import org.hibernate.metamodel.mapping.MappingModelHelper; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.Joinable; -import org.hibernate.query.NavigablePath; import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.query.sqm.internal.DomainParameterXref; @@ -42,7 +41,6 @@ import org.hibernate.sql.ast.tree.delete.DeleteStatement; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.SqlTuple; -import org.hibernate.sql.ast.tree.from.MutatingTableReferenceGroupWrapper; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.predicate.InSubQueryPredicate; @@ -50,9 +48,8 @@ import org.hibernate.sql.ast.tree.predicate.Predicate; 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; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java index 2af4706041..24fb247dfa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/TableBasedUpdateHandler.java @@ -38,7 +38,7 @@ import org.hibernate.sql.ast.tree.from.TableReferenceJoin; import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.update.Assignment; import org.hibernate.sql.exec.spi.ExecutionContext; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java index 4e0174ab93..e10912cd42 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/UpdateExecutionDelegate.java @@ -36,7 +36,7 @@ import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.update.Assignment; import org.hibernate.sql.ast.tree.update.UpdateStatement; 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; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/PatternRenderer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/PatternRenderer.java index ac87f923de..50863cc901 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/PatternRenderer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/internal/PatternRenderer.java @@ -15,7 +15,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/FunctionAsExpressionTemplate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/FunctionAsExpressionTemplate.java index 8cd7303d4c..e40189f70d 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/FunctionAsExpressionTemplate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/FunctionAsExpressionTemplate.java @@ -15,7 +15,7 @@ import org.hibernate.query.sqm.produce.function.ArgumentsValidator; import org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver; import org.hibernate.query.sqm.tree.SqmTypedNode; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/NamedSqmFunctionTemplate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/NamedSqmFunctionTemplate.java index 28a87274b3..b5f3d19780 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/NamedSqmFunctionTemplate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/NamedSqmFunctionTemplate.java @@ -13,7 +13,7 @@ import org.hibernate.query.sqm.produce.function.ArgumentsValidator; import org.hibernate.query.sqm.produce.function.FunctionReturnTypeResolver; import org.hibernate.query.sqm.tree.SqmTypedNode; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/PatternBasedSqmFunctionTemplate.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/PatternBasedSqmFunctionTemplate.java index cbc7e15328..228cd021c0 100755 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/PatternBasedSqmFunctionTemplate.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/PatternBasedSqmFunctionTemplate.java @@ -15,7 +15,7 @@ import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators; import org.hibernate.query.sqm.produce.function.internal.PatternRenderer; import org.hibernate.query.sqm.tree.SqmTypedNode; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/SelfRenderingFunctionSupport.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/SelfRenderingFunctionSupport.java index 085222b8bb..bfc654fd98 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/SelfRenderingFunctionSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/produce/function/spi/SelfRenderingFunctionSupport.java @@ -8,7 +8,7 @@ package org.hibernate.query.sqm.produce.function.spi; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/JdbcParameterBySqmParameterAccess.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/JdbcParameterBySqmParameterAccess.java index 40cef4dc4c..e8926d3ed5 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/JdbcParameterBySqmParameterAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/spi/JdbcParameterBySqmParameterAccess.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Map; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * Access to the mapping between an SqmParameter and all of its JDBC parameters diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java index 3aba25bc32..21ea1c6f7f 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/BaseSqmToSqlAstConverter.java @@ -137,10 +137,10 @@ import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.exec.internal.JdbcParameterImpl; import org.hibernate.sql.exec.internal.JdbcParametersImpl; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.exec.spi.JdbcParameters; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.FetchParent; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParent; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmDeleteTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmDeleteTranslation.java index bd3546b0dd..0e52133e7a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmDeleteTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmDeleteTranslation.java @@ -13,7 +13,7 @@ import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.tree.delete.DeleteStatement; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmUpdateTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmUpdateTranslation.java index 382177a4e4..ef8b519a6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmUpdateTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SimpleSqmUpdateTranslation.java @@ -10,9 +10,8 @@ import java.util.List; import java.util.Map; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.ast.tree.delete.DeleteStatement; import org.hibernate.sql.ast.tree.update.UpdateStatement; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmInsertSelectTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmInsertSelectTranslation.java index 5985cf36b8..d4c4169a89 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmInsertSelectTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmInsertSelectTranslation.java @@ -11,7 +11,7 @@ import java.util.Map; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.sql.ast.tree.insert.InsertSelectStatement; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmQuerySpecTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmQuerySpecTranslation.java index 55f180386a..52b8c0ea96 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmQuerySpecTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmQuerySpecTranslation.java @@ -11,7 +11,7 @@ import java.util.Map; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.sql.ast.tree.select.QuerySpec; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmSelectTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmSelectTranslation.java index 7013ca5c4c..3af678379a 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmSelectTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmSelectTranslation.java @@ -12,7 +12,7 @@ import java.util.Map; import org.hibernate.query.sqm.sql.internal.StandardSqmSelectTranslator; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.sql.ast.tree.select.SelectStatement; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * Details of the result of interpreting an SQM SELECT AST into a SQL SELECT AST diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmTranslation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmTranslation.java index 822dc7adaa..3b6960e6aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmTranslation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/SqmTranslation.java @@ -11,7 +11,7 @@ import java.util.Map; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.sql.ast.tree.Statement; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * Information obtained from the interpretation of an SqmStatement diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java index d0cea37775..ef770d10df 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/BasicValuedPathInterpretation.java @@ -19,15 +19,15 @@ import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.query.sqm.tree.domain.SqmBasicValuedSimplePath; import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.spi.SqlAstCreationContext; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.update.Assignment; -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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DomainResultProducer.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DomainResultProducer.java index 28f23e1ac3..edd84f9059 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DomainResultProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/DomainResultProducer.java @@ -10,8 +10,8 @@ import java.util.function.Consumer; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.JdbcMapping; -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.spi.TypeConfiguration; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java index 4cdfdcbd74..17c1f0cbfe 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EmbeddableValuedPathInterpretation.java @@ -18,14 +18,14 @@ import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.tree.domain.SqmEmbeddedValuedSimplePath; import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.spi.SqlAstCreationContext; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.SqlTuple; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.update.Assignment; -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 diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java index 09ce2574d9..a9ca3c9321 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/EntityValuedPathInterpretation.java @@ -11,10 +11,10 @@ import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.sqm.tree.domain.SqmEntityValuedSimplePath; import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.sql.ast.spi.SqlAstCreationState; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; 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; /** * @author Koen Aers diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstProcessingStateImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstProcessingStateImpl.java index 808cab5123..fe302f9df6 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstProcessingStateImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstProcessingStateImpl.java @@ -132,9 +132,4 @@ public class SqlAstProcessingStateImpl implements SqlAstProcessingState, SqlExpr TypeConfiguration typeConfiguration) { throw new ConversionException( "Unexpected call to resolve SqlSelection outside of QuerySpec processing" ); } - - @Override - public SqlSelection emptySqlSelection() { - throw new ConversionException( "Unexpected call to resolve SqlSelection outside of QuerySpec processing" ); - } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQuerySpecProcessingStateImpl.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQuerySpecProcessingStateImpl.java index 0300423df0..1d3b5f9972 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQuerySpecProcessingStateImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqlAstQuerySpecProcessingStateImpl.java @@ -8,19 +8,15 @@ package org.hibernate.query.sqm.sql.internal; import java.util.HashMap; import java.util.Map; -import java.util.function.Consumer; import java.util.function.Supplier; -import org.hibernate.metamodel.mapping.MappingModelExpressable; +import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.SqlAstCreationState; import org.hibernate.sql.ast.spi.SqlAstProcessingState; import org.hibernate.sql.ast.spi.SqlAstQuerySpecProcessingState; -import org.hibernate.sql.ast.Clause; -import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.select.QuerySpec; -import org.hibernate.sql.results.internal.EmptySqlSelection; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; @@ -52,7 +48,6 @@ public class SqlAstQuerySpecProcessingStateImpl // SqlExpressionResolver private Map sqlSelectionMap; - private int nonEmptySelections = 0; @Override protected Map sqlSelectionMap() { @@ -77,55 +72,18 @@ public class SqlAstQuerySpecProcessingStateImpl return existing; } + final int valuesArrayPosition = sqlSelectionMap.size(); final SqlSelection sqlSelection = expression.createSqlSelection( - nonEmptySelections + 1, - sqlSelectionMap.size(), + valuesArrayPosition + 1, + valuesArrayPosition, javaTypeDescriptor, typeConfiguration ); sqlSelectionMap.put( expression, sqlSelection ); - if ( !( sqlSelection instanceof EmptySqlSelection ) ) { - nonEmptySelections++; - } - querySpec.getSelectClause().addSqlSelection( sqlSelection ); return sqlSelection; } - - @Override - public SqlSelection emptySqlSelection() { - final EmptySqlSelection sqlSelection = new EmptySqlSelection( sqlSelectionMap.size() ); - sqlSelectionMap.put( EmptyExpression.EMPTY_EXPRESSION, sqlSelection ); - return sqlSelection; - } - - public static class EmptyExpression implements Expression { - @SuppressWarnings("WeakerAccess") - public static final EmptyExpression EMPTY_EXPRESSION = new EmptyExpression(); - - private EmptyExpression() { - } - - @Override - public SqlSelection createSqlSelection( - int jdbcPosition, - int valuesArrayPosition, - JavaTypeDescriptor javaTypeDescriptor, - TypeConfiguration typeConfiguration) { - return null; - } - - @Override - public MappingModelExpressable getExpressionType() { - return null; - } - - @Override - public void accept(SqlAstWalker sqlTreeWalker) { - - } - } } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java index 23fed0c9ae..46b24a8e73 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/SqmParameterInterpretation.java @@ -15,14 +15,14 @@ import org.hibernate.query.SemanticException; import org.hibernate.query.spi.QueryParameterBinding; import org.hibernate.query.spi.QueryParameterImplementor; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.SqlTuple; -import org.hibernate.sql.exec.spi.JdbcParameter; -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.ast.tree.expression.JdbcParameter; +import org.hibernate.sql.results.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmSelectTranslator.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmSelectTranslator.java index 8e47fb567f..6529caa1a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmSelectTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmSelectTranslator.java @@ -55,14 +55,14 @@ import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableGroupJoinProducer; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; -import org.hibernate.sql.results.internal.domain.instantiation.DynamicInstantiation; +import org.hibernate.sql.results.graph.instantiation.internal.DynamicInstantiation; import org.hibernate.sql.results.spi.CircularFetchDetector; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.sql.results.spi.EntityResultNode; -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.entity.EntityResultGraphNode; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.Fetchable; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** @@ -251,8 +251,8 @@ public class StandardSqmSelectTranslator } } else if ( fetchInfluencers.hasEnabledFetchProfiles() ) { - if ( fetchParent instanceof EntityResultNode ) { - final EntityResultNode entityFetchParent = (EntityResultNode) fetchParent; + if ( fetchParent instanceof EntityResultGraphNode ) { + final EntityResultGraphNode entityFetchParent = (EntityResultGraphNode) fetchParent; final EntityMappingType entityMappingType = entityFetchParent.getEntityValuedModelPart().getEntityMappingType(); final String fetchParentEntityName = entityMappingType.getEntityName(); final String fetchableRole = fetchParentEntityName + "." + fetchable.getFetchableName(); @@ -341,11 +341,11 @@ public class StandardSqmSelectTranslator } private static boolean appliesTo(GraphImplementor graphNode, FetchParent fetchParent) { - if ( ! ( fetchParent instanceof EntityResultNode ) ) { + if ( ! ( fetchParent instanceof EntityResultGraphNode ) ) { return false; } - final EntityResultNode entityFetchParent = (EntityResultNode) fetchParent; + final EntityResultGraphNode entityFetchParent = (EntityResultGraphNode) fetchParent; final EntityMappingType entityFetchParentMappingType = entityFetchParent.getEntityValuedModelPart().getEntityMappingType(); assert graphNode.getGraphedType() instanceof EntityDomainType; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmUpdateTranslator.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmUpdateTranslator.java index 3abb1724ad..2e4b379700 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmUpdateTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/sql/internal/StandardSqmUpdateTranslator.java @@ -23,7 +23,6 @@ import org.hibernate.query.sqm.sql.BaseSqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SimpleSqmUpdateTranslation; import org.hibernate.query.sqm.sql.SimpleSqmUpdateTranslator; import org.hibernate.query.sqm.tree.cte.SqmCteStatement; -import org.hibernate.query.sqm.tree.expression.SqmNamedParameter; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.query.sqm.tree.predicate.SqmWhereClause; import org.hibernate.query.sqm.tree.update.SqmAssignment; @@ -45,7 +44,7 @@ import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.ast.tree.update.Assignment; import org.hibernate.sql.ast.tree.update.UpdateStatement; import org.hibernate.sql.exec.internal.JdbcParameterImpl; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.type.spi.TypeConfiguration; /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmJpaCriteriaParameterWrapper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmJpaCriteriaParameterWrapper.java index 402c76f6ef..c9e4a54b95 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmJpaCriteriaParameterWrapper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/expression/SqmJpaCriteriaParameterWrapper.java @@ -12,6 +12,7 @@ import org.hibernate.metamodel.model.domain.AllowableParameterType; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.tree.select.SqmSelectableNode; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; /** * @author Steve Ebersole @@ -82,7 +83,7 @@ public class SqmJpaCriteriaParameterWrapper * as part of {@link SemanticQueryWalker#visitJpaCriteriaParameter}. This wrapper * is intended just for representing unique SqmParameter references for each * JpaCriteriaParameter occurence in the SQM true as part of the {@link org.hibernate.query.QueryParameter} - * -> {@link SqmParameter} -> {@link org.hibernate.sql.exec.spi.JdbcParameter} transformation. + * -> {@link SqmParameter} -> {@link JdbcParameter} transformation. * Each occurrence requires a unique SqmParameter to make sure we ultimately get the complete * set of JdbcParameter references */ diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmRoot.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmRoot.java index 86ea99a709..4180ce0028 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmRoot.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmRoot.java @@ -23,8 +23,8 @@ import org.hibernate.query.sqm.tree.domain.SqmPath; import org.hibernate.query.sqm.tree.domain.SqmTreatedPath; import org.hibernate.query.sqm.tree.domain.SqmTreatedRoot; import org.hibernate.sql.ast.Clause; -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; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstDeleteTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstDeleteTranslator.java index 76e1b8336c..264e8675de 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstDeleteTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstDeleteTranslator.java @@ -7,7 +7,6 @@ package org.hibernate.sql.ast; import org.hibernate.sql.ast.spi.SqlAstToJdbcOperationConverter; -import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.tree.cte.CteStatement; import org.hibernate.sql.ast.tree.delete.DeleteStatement; import org.hibernate.sql.exec.spi.JdbcDelete; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslator.java index 6069d353a6..bc75de5263 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslator.java @@ -8,7 +8,6 @@ package org.hibernate.sql.ast; import java.util.Set; -import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.tree.cte.CteStatement; import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators; @@ -30,7 +29,7 @@ public interface SqlAstTranslator extends SqlAstWalker, SqlTypeDescriptorIndicat * Generalized support for translating a CTE statement. The underlying * {@link CteStatement#getCteConsumer()} could be a SELECT, UPDATE, DELETE, etc. * - * Implementors may throw an exception is the CTE-consumer is of the incorrect type + * Implementors may throw an exception if the CTE-consumer is of the incorrect type */ JdbcOperation translate(CteStatement cteStatement); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstWalker.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstWalker.java rename to hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstWalker.java index d148fc1cbc..4e8cda86f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstWalker.java @@ -4,27 +4,27 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.ast.spi; +package org.hibernate.sql.ast; -import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.Incubating; +import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.EntityTypeLiteral; import org.hibernate.sql.ast.tree.expression.JdbcLiteral; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.expression.QueryLiteral; import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression; import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression; import org.hibernate.sql.ast.tree.expression.SqlTuple; import org.hibernate.sql.ast.tree.expression.UnaryOperation; -import org.hibernate.sql.ast.tree.from.CompositeTableGroup; import org.hibernate.sql.ast.tree.from.FromClause; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.from.TableReferenceJoin; -import org.hibernate.sql.ast.tree.from.VirtualTableGroup; import org.hibernate.sql.ast.tree.predicate.BetweenPredicate; import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate; import org.hibernate.sql.ast.tree.predicate.FilterPredicate; @@ -40,16 +40,13 @@ import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.ast.tree.update.Assignment; -import org.hibernate.sql.exec.spi.JdbcParameter; /** * @author Steve Ebersole * @author Andrea Boriero */ +@Incubating public interface SqlAstWalker { - - SessionFactoryImplementor getSessionFactory(); - void visitAssignment(Assignment assignment); void visitQuerySpec(QuerySpec querySpec); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java index 34625fb5fd..261345e4ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlTreePrinter.java @@ -10,8 +10,6 @@ import java.util.Locale; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.SortOrder; -import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.ast.spi.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.SqlAstTreeLogger; import org.hibernate.sql.ast.tree.Statement; @@ -22,6 +20,7 @@ import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression; import org.hibernate.sql.ast.tree.expression.ColumnReference; import org.hibernate.sql.ast.tree.expression.EntityTypeLiteral; import org.hibernate.sql.ast.tree.expression.JdbcLiteral; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.expression.QueryLiteral; import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression; import org.hibernate.sql.ast.tree.expression.SqlSelectionExpression; @@ -50,7 +49,6 @@ import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.ast.tree.update.Assignment; import org.hibernate.sql.ast.tree.update.UpdateStatement; -import org.hibernate.sql.exec.spi.JdbcParameter; /** * @author Steve Ebersole @@ -73,13 +71,6 @@ public class SqlTreePrinter implements SqlAstWalker { private SqlTreePrinter() { } - @Override - public SessionFactoryImplementor getSessionFactory() { - // should not be needed. - // todo (6.0) : in fact we really should consider dropping this from the interface - return null; - } - private void visitStatement(Statement sqlAstStatement) { if ( sqlAstStatement instanceof SelectStatement ) { logNode( @@ -179,6 +170,10 @@ public class SqlTreePrinter implements SqlAstWalker { logWithIndentation( "-> [" + String.format( pattern, arg ) + ']'); } + private void logNode(String pattern, Object arg, Object arg2) { + logWithIndentation( "-> [" + String.format( pattern, arg, arg2 ) + ']'); + } + private void logNode(String text, Runnable subTreeHandler) { logNode( text, subTreeHandler, false ); } @@ -379,7 +374,7 @@ public class SqlTreePrinter implements SqlAstWalker { @Override public void visitColumnReference(ColumnReference columnReference) { - logNode( columnReference.renderSqlFragment( getSessionFactory() ) ); + logNode( "{%s}.{%s}", columnReference.getQualifier(), columnReference.getColumnExpression() ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/ANSICaseExpressionWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/ANSICaseExpressionWalker.java index b8750703ca..5f25826c27 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/ANSICaseExpressionWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/ANSICaseExpressionWalker.java @@ -6,6 +6,7 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.Expression; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java index a6c8d977dd..46bededc4f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/AbstractSqlAstWalker.java @@ -20,6 +20,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.query.QueryLiteralRendering; import org.hibernate.query.UnaryArithmeticOperator; import org.hibernate.sql.ast.Clause; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.BinaryArithmeticExpression; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.CaseSimpleExpression; @@ -55,9 +56,8 @@ import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SortSpecification; import org.hibernate.sql.exec.internal.JdbcParametersImpl; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.exec.spi.JdbcParameterBinder; -import org.hibernate.sql.results.internal.EmptySqlSelection; import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators; import org.hibernate.type.spi.TypeConfiguration; @@ -95,6 +95,10 @@ public abstract class AbstractSqlAstWalker this.dialect = sessionFactory.getJdbcServices().getDialect(); } + public SessionFactoryImplementor getSessionFactory() { + return sessionFactory; + } + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // for tests, for now @@ -250,9 +254,6 @@ public abstract class AbstractSqlAstWalker String separator = NO_SEPARATOR; for ( SqlSelection sqlSelection : selectClause.getSqlSelections() ) { - if ( sqlSelection instanceof EmptySqlSelection ) { - continue; - } appendSql( separator ); sqlSelection.accept( this ); separator = COMA_SEPARATOR; @@ -1056,9 +1057,4 @@ public abstract class AbstractSqlAstWalker public TypeConfiguration getTypeConfiguration() { return getSessionFactory().getTypeConfiguration(); } - - @Override - public SessionFactoryImplementor getSessionFactory() { - return sessionFactory; - } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/CaseExpressionWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/CaseExpressionWalker.java index 8dc8555ff5..24a080c6a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/CaseExpressionWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/CaseExpressionWalker.java @@ -6,6 +6,7 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DecodeCaseExpressionWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DecodeCaseExpressionWalker.java index 63dc89dd14..8fcd17f4f9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DecodeCaseExpressionWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DecodeCaseExpressionWalker.java @@ -8,6 +8,7 @@ package org.hibernate.sql.ast.spi; import java.util.List; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DerbyCaseExpressionWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DerbyCaseExpressionWalker.java index f3f44f2d8a..7d20e4ab4e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DerbyCaseExpressionWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/DerbyCaseExpressionWalker.java @@ -6,6 +6,7 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.expression.QueryLiteral; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/MckoiCaseExpressionWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/MckoiCaseExpressionWalker.java index ca2894b864..26e32ca055 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/MckoiCaseExpressionWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/MckoiCaseExpressionWalker.java @@ -6,9 +6,9 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression; import org.hibernate.sql.ast.tree.expression.Expression; -import org.hibernate.sql.ast.tree.predicate.NullnessPredicate; /** * @author Andrea Boriero diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstCreationState.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstCreationState.java index d162249686..cd580731a7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstCreationState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstCreationState.java @@ -9,8 +9,8 @@ package org.hibernate.sql.ast.spi; import java.util.List; import org.hibernate.LockMode; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.FetchParent; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParent; /** * todo (6.0) : most of this is SQM -> SQL specific. Should move to that package. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstToJdbcOperationConverter.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstToJdbcOperationConverter.java index 1fcf269796..4a178ac8a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstToJdbcOperationConverter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlAstToJdbcOperationConverter.java @@ -8,6 +8,7 @@ package org.hibernate.sql.ast.spi; import java.util.Set; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.cte.CteStatement; import org.hibernate.sql.exec.spi.JdbcOperation; import org.hibernate.type.descriptor.sql.SqlTypeDescriptorIndicators; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java index 526a2c3e8f..bb68a67b36 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlExpressionResolver.java @@ -64,6 +64,4 @@ public interface SqlExpressionResolver { Expression expression, JavaTypeDescriptor javaTypeDescriptor, TypeConfiguration typeConfiguration); - - SqlSelection emptySqlSelection(); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectAstWalker.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectAstWalker.java index 5a3e9e0d82..538bbe3f51 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectAstWalker.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectAstWalker.java @@ -6,6 +6,8 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.ast.SqlAstWalker; + /** * @author Steve Ebersole * @author Andrea Boriero diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelection.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelection.java index 7095feae45..2f0dfd8c09 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelection.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelection.java @@ -7,8 +7,9 @@ package org.hibernate.sql.ast.spi; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.type.descriptor.ValueExtractor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java index e397d2aa03..86ff9d2db9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/SqlSelectionProducer.java @@ -6,6 +6,7 @@ */ package org.hibernate.sql.ast.spi; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; @@ -17,7 +18,7 @@ public interface SqlSelectionProducer { * Create a SqlSelection for the given JDBC ResultSet position * * @param jdbcPosition The index position used to read values from JDBC - * @param valuesArrayPosition The position in our {@linkplain org.hibernate.sql.results.spi.RowProcessingState#getJdbcValue(org.hibernate.sql.ast.spi.SqlSelection) "current JDBC values array"} + * @param valuesArrayPosition The position in our {@linkplain RowProcessingState#getJdbcValue(org.hibernate.sql.ast.spi.SqlSelection) "current JDBC values array"} * @param javaTypeDescriptor The descriptor for the Java type to read the value as * @param typeConfiguration The associated TypeConfiguration */ diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java index 4ebdc549f8..01d5499b35 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java @@ -18,7 +18,7 @@ import org.hibernate.sql.ast.tree.cte.CteStatement; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcSelect; -import org.hibernate.sql.results.internal.JdbcValuesMappingProducerStandard; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesMappingProducerStandard; /** * The final phase of query translation. Here we take the SQL-AST an diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/SqlAstNode.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/SqlAstNode.java index 12ed18057b..59cfcde5cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/SqlAstNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/SqlAstNode.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java index 5a62cbc0b2..5f3d445e40 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java @@ -25,7 +25,7 @@ import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.exec.internal.JdbcParameterImpl; 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.results.internal.SqlSelectionImpl; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/AbstractLiteral.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/AbstractLiteral.java index 33c6a7d18b..5b8aeac6b5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/AbstractLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/AbstractLiteral.java @@ -20,9 +20,9 @@ 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.results.internal.SqlSelectionImpl; -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.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.type.BasicType; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java index 07f0624f68..937cbf3ed9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/BinaryArithmeticExpression.java @@ -9,7 +9,7 @@ package org.hibernate.sql.ast.tree.expression; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.BinaryArithmeticOperator; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSearchedExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSearchedExpression.java index d7b1dc8f11..b405c247e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSearchedExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSearchedExpression.java @@ -12,13 +12,13 @@ import java.util.List; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.predicate.Predicate; import org.hibernate.sql.results.internal.SqlSelectionImpl; -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.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.type.BasicType; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSimpleExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSimpleExpression.java index 189de5d1ca..1482db9800 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSimpleExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/CaseSimpleExpression.java @@ -13,10 +13,9 @@ import java.util.List; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAstWalker; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.type.descriptor.java.JavaTypeDescriptor; +import org.hibernate.sql.ast.SqlAstWalker; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java index cf6b06d8f0..8272bf9296 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/ColumnReference.java @@ -17,7 +17,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.MappingModelExpressable; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.from.TableReference; import org.hibernate.sql.ast.tree.update.Assignable; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/EntityTypeLiteral.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/EntityTypeLiteral.java index 0e9b1c48a2..e583332e53 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/EntityTypeLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/EntityTypeLiteral.java @@ -9,7 +9,7 @@ package org.hibernate.sql.ast.tree.expression; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.Queryable; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.type.Type; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcLiteral.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcLiteral.java index b5300b2486..8580f34d78 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcLiteral.java @@ -18,15 +18,15 @@ import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.SqlAstCreationState; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.JdbcParameterBindings; import org.hibernate.sql.results.internal.SqlSelectionImpl; -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.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameter.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcParameter.java similarity index 78% rename from hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameter.java rename to hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcParameter.java index 86bd70c8c5..23f8c9f377 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/JdbcParameter.java @@ -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.sql.exec.spi; +package org.hibernate.sql.ast.tree.expression; -import org.hibernate.sql.ast.tree.expression.Expression; +import org.hibernate.sql.exec.spi.JdbcParameterBinder; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/QueryLiteral.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/QueryLiteral.java index 7f6de80609..128f02ee47 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/QueryLiteral.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/QueryLiteral.java @@ -13,15 +13,15 @@ import java.util.function.Consumer; import org.hibernate.metamodel.mapping.BasicValuedMapping; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.exec.spi.JdbcParameterBindings; import org.hibernate.sql.results.internal.SqlSelectionImpl; -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.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.type.BasicType; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.hibernate.type.spi.TypeConfiguration; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SelfRenderingExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SelfRenderingExpression.java index 4f5e92b026..14a5966dba 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SelfRenderingExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SelfRenderingExpression.java @@ -8,7 +8,7 @@ package org.hibernate.sql.ast.tree.expression; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlSelectionExpression.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlSelectionExpression.java index 5cd20b47d2..a987c9f523 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlSelectionExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlSelectionExpression.java @@ -8,7 +8,7 @@ package org.hibernate.sql.ast.tree.expression; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * Represents a selection that is "re-used" in certain parts of the query diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlTuple.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlTuple.java index b199a6235e..90f7271f40 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlTuple.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/SqlTuple.java @@ -11,8 +11,7 @@ import java.util.Collections; import java.util.List; import org.hibernate.metamodel.mapping.MappingModelExpressable; -import org.hibernate.metamodel.mapping.ModelPart; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/UnaryOperation.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/UnaryOperation.java index 238ce5733e..8d223419aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/UnaryOperation.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/expression/UnaryOperation.java @@ -11,10 +11,9 @@ import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.query.UnaryArithmeticOperator; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAstWalker; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.type.descriptor.java.JavaTypeDescriptor; +import org.hibernate.sql.ast.SqlAstWalker; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/FromClause.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/FromClause.java index 0ac1d67136..b689d5c291 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/FromClause.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/FromClause.java @@ -11,7 +11,7 @@ import java.util.List; import java.util.function.Consumer; import org.hibernate.internal.util.collections.CollectionHelper; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java index 7b846dae4a..492dd327d2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroup.java @@ -14,13 +14,11 @@ import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.query.NavigablePath; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.ast.spi.SqlAliasBase; -import org.hibernate.sql.ast.spi.SqlAppender; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.expression.ColumnReference; -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; /** * Group together {@link TableReference} references related to a single entity or diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroupJoin.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroupJoin.java index 7cfa7b189d..24a3611334 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroupJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableGroupJoin.java @@ -9,11 +9,11 @@ package org.hibernate.sql.ast.tree.from; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.JoinType; import org.hibernate.sql.ast.spi.SqlAstTreeHelper; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; 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; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReference.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReference.java index d068a9cb5c..a072ddda54 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReference.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReference.java @@ -12,7 +12,7 @@ import java.util.Objects; import java.util.function.Supplier; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.expression.ColumnReference; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReferenceJoin.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReferenceJoin.java index db16bc2503..74910e1d51 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReferenceJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/from/TableReferenceJoin.java @@ -7,7 +7,7 @@ package org.hibernate.sql.ast.tree.from; import org.hibernate.sql.ast.JoinType; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.predicate.Predicate; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/BetweenPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/BetweenPredicate.java index e2b66d666e..d962c717b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/BetweenPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/BetweenPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/ComparisonPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/ComparisonPredicate.java index df7d78ed41..5ca70dc9b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/ComparisonPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/ComparisonPredicate.java @@ -7,7 +7,7 @@ package org.hibernate.sql.ast.tree.predicate; import org.hibernate.query.ComparisonOperator; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/FilterPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/FilterPredicate.java index ef823048a5..9fbd52255a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/FilterPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/FilterPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * Represents a filter applied to an entity/collection. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/GroupedPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/GroupedPredicate.java index d742d30205..7157a75e90 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/GroupedPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/GroupedPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InListPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InListPredicate.java index e92b21b259..cbef5496f2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InListPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InListPredicate.java @@ -10,7 +10,7 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.internal.util.collections.ArrayHelper; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InSubQueryPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InSubQueryPredicate.java index a8500c543b..f055552cda 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InSubQueryPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/InSubQueryPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.sql.ast.tree.select.QuerySpec; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/Junction.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/Junction.java index f37305d96a..f6ad8c5275 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/Junction.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/Junction.java @@ -9,7 +9,7 @@ package org.hibernate.sql.ast.tree.predicate; import java.util.ArrayList; import java.util.List; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/LikePredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/LikePredicate.java index cfb6d65840..7863a5bb7f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/LikePredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/LikePredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NegatedPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NegatedPredicate.java index 504b855a32..5553e06e3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NegatedPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NegatedPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NullnessPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NullnessPredicate.java index ba50ff6059..576c167e3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NullnessPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/NullnessPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.Expression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/SelfRenderingPredicate.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/SelfRenderingPredicate.java index c512d928bd..0bfe8a515b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/SelfRenderingPredicate.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/predicate/SelfRenderingPredicate.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.predicate; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.expression.SelfRenderingExpression; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/QuerySpec.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/QuerySpec.java index e87278d9d9..204ee89194 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/QuerySpec.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/QuerySpec.java @@ -12,7 +12,7 @@ import java.util.function.Consumer; import org.hibernate.metamodel.mapping.MappingModelExpressable; import org.hibernate.sql.ast.spi.SqlAstTreeHelper; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.cte.CteConsumer; import org.hibernate.sql.ast.tree.expression.Expression; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectClause.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectClause.java index bf7716c405..e1a7a2c6b6 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectClause.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectClause.java @@ -7,13 +7,11 @@ package org.hibernate.sql.ast.tree.select; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; -import org.hibernate.sql.results.spi.DomainResult; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectStatement.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectStatement.java index d03345e5f6..1039c85b86 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectStatement.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SelectStatement.java @@ -10,7 +10,7 @@ import java.util.Collections; import java.util.List; import org.hibernate.sql.ast.tree.Statement; -import org.hibernate.sql.results.spi.DomainResult; +import org.hibernate.sql.results.graph.DomainResult; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SortSpecification.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SortSpecification.java index abeb2dd59b..9579c3c433 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SortSpecification.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/select/SortSpecification.java @@ -7,7 +7,7 @@ package org.hibernate.sql.ast.tree.select; import org.hibernate.SortOrder; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.expression.Expression; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/update/Assignment.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/update/Assignment.java index 83e2f0e0c1..a5c17e3a94 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/update/Assignment.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/update/Assignment.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.ast.tree.update; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.SqlAstNode; import org.hibernate.sql.ast.tree.expression.Expression; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java index c612e55ff8..6021fdd160 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/AbstractJdbcParameter.java @@ -18,7 +18,7 @@ import org.hibernate.sql.ast.Clause; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.exec.ExecutionException; 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.JdbcParameterBinder; import org.hibernate.sql.exec.spi.JdbcParameterBinding; import org.hibernate.sql.exec.spi.JdbcParameterBindings; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterBindingsImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterBindingsImpl.java index fb9f4ffe72..f082ea87a6 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterBindingsImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterBindingsImpl.java @@ -12,8 +12,7 @@ import java.util.IdentityHashMap; import java.util.Map; import java.util.function.BiConsumer; -import org.hibernate.query.sqm.internal.DomainParameterXref; -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; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterImpl.java index 5bdbe5e5f4..e8eb5ba0cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParameterImpl.java @@ -7,7 +7,7 @@ package org.hibernate.sql.exec.internal; import org.hibernate.metamodel.mapping.JdbcMapping; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParametersImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParametersImpl.java index 351e758126..1035f0a7eb 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParametersImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcParametersImpl.java @@ -11,7 +11,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.Set; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.exec.spi.JdbcParameters; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java index da3c45e7d6..11e5bd46e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/internal/JdbcSelectExecutorStandardImpl.java @@ -20,23 +20,23 @@ import org.hibernate.CacheMode; import org.hibernate.ScrollMode; import org.hibernate.cache.spi.QueryKey; import org.hibernate.cache.spi.QueryResultsCache; -import org.hibernate.loader.spi.AfterLoadAction; +import org.hibernate.loader.ast.spi.AfterLoadAction; import org.hibernate.query.internal.ScrollableResultsIterator; import org.hibernate.query.spi.ScrollableResultsImplementor; import org.hibernate.sql.exec.spi.ExecutionContext; 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.internal.DeferredResultSetAccess; +import org.hibernate.sql.results.jdbc.internal.DeferredResultSetAccess; import org.hibernate.sql.results.internal.Helper; -import org.hibernate.sql.results.internal.JdbcValuesCacheHit; -import org.hibernate.sql.results.internal.JdbcValuesResultSetImpl; -import org.hibernate.sql.results.internal.JdbcValuesSourceProcessingStateStandardImpl; -import org.hibernate.sql.results.internal.ResultSetAccess; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesCacheHit; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesResultSetImpl; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl; +import org.hibernate.sql.results.jdbc.internal.ResultSetAccess; import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl; -import org.hibernate.sql.results.spi.JdbcValues; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; import org.hibernate.sql.results.spi.ListResultsConsumer; import org.hibernate.sql.results.spi.ResultsConsumer; import org.hibernate.sql.results.spi.RowReader; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/package-info.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/package-info.java index d9381fb5eb..77f0d5dcf9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/package-info.java @@ -10,8 +10,8 @@ * to execute is modelled by {@link org.hibernate.sql.exec.spi.JdbcOperation} and * are executed via the corresponding executor. * - * For operations that return ResultSets, be sure to see {@link org.hibernate.sql.results} + * For operations that return ResultSets, be sure to see {@link org.hibernate.loader.ast.results} * which provides support for processing results starting with - * {@link org.hibernate.sql.results.spi.JdbcValuesMapping} + * {@link org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping} */ package org.hibernate.sql.exec; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/Callback.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/Callback.java index 9c8311ce89..c34106e414 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/Callback.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/Callback.java @@ -7,7 +7,7 @@ package org.hibernate.sql.exec.spi; -import org.hibernate.loader.spi.AfterLoadAction; +import org.hibernate.loader.ast.spi.AfterLoadAction; /** * Callback to allow SQM interpretation to trigger certain things within ORM. See the current diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java index ef5b5fdaae..a754c0fd02 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/ExecutionContext.java @@ -6,8 +6,6 @@ */ package org.hibernate.sql.exec.spi; -import java.util.function.BiConsumer; - import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.LoadQueryInfluencers; @@ -15,7 +13,7 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; -import org.hibernate.sql.results.spi.LoadingEntityEntry; +import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcAnonBlock.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcAnonBlock.java index 8703a16fc4..d315986811 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcAnonBlock.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcAnonBlock.java @@ -6,7 +6,7 @@ */ package org.hibernate.sql.exec.spi; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; /** * An anonymous call block (sometimes called an anonymous procedure) to be executed diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java index 101232dc21..a4b44f18d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameterBindings.java @@ -10,6 +10,8 @@ import java.util.Collection; import java.util.Collections; import java.util.function.BiConsumer; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; + /** * Access to all of the externalized JDBC parameter bindings * diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameters.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameters.java index 09535ad294..6a681f6f58 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameters.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcParameters.java @@ -10,6 +10,8 @@ import java.util.Collection; import java.util.Set; import java.util.function.Consumer; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; + /** * The collection * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcSelect.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcSelect.java index 3b54a5fe5e..2dd1cc2417 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcSelect.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/JdbcSelect.java @@ -9,7 +9,7 @@ package org.hibernate.sql.exec.spi; import java.util.List; import java.util.Set; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; /** * Executable JDBC command diff --git a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/StandardEntityInstanceResolver.java b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/StandardEntityInstanceResolver.java index cce135df75..ba415a29e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/StandardEntityInstanceResolver.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/exec/spi/StandardEntityInstanceResolver.java @@ -8,7 +8,7 @@ package org.hibernate.sql.exec.spi; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.sql.results.spi.LoadingEntityEntry; +import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/DomainResultCreationException.java b/hibernate-core/src/main/java/org/hibernate/sql/results/DomainResultCreationException.java index 042f0c7244..2d93edfd56 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/DomainResultCreationException.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/DomainResultCreationException.java @@ -7,9 +7,10 @@ package org.hibernate.sql.results; import org.hibernate.HibernateException; +import org.hibernate.sql.results.graph.DomainResult; /** - * Base for problems creating {@link org.hibernate.sql.results.spi.DomainResult} + * Base for problems creating {@link DomainResult} * instances * * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/SqlResultsLogger.java b/hibernate-core/src/main/java/org/hibernate/sql/results/ResultsLogger.java similarity index 68% rename from hibernate-core/src/main/java/org/hibernate/sql/results/SqlResultsLogger.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/ResultsLogger.java index 553cba85b1..99e72bd42e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/SqlResultsLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/ResultsLogger.java @@ -12,18 +12,26 @@ import org.jboss.logging.annotations.MessageLogger; import org.jboss.logging.annotations.ValidIdRange; /** + * @asciidoc + * + * Logger for DomainResult related messages. This includes messages related to: + * + * * creation of the DomainResult / Fetch nodes + * * creation of Initializer / DomainResultAssembler delegates + * * processing of JDBC values via Initializer / DomainResultAssembler + * * @author Steve Ebersole */ @MessageLogger( projectCode = "HHH" ) @ValidIdRange( min = 90005001, max = 90005100 ) -public interface SqlResultsLogger extends BasicLogger { +public interface ResultsLogger extends BasicLogger { String LOGGER_NAME = "org.hibernate.orm.sql.results"; /** * Static access to the logging instance */ - SqlResultsLogger INSTANCE = Logger.getMessageLogger( - SqlResultsLogger.class, + ResultsLogger INSTANCE = Logger.getMessageLogger( + ResultsLogger.class, LOGGER_NAME ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManager.java b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/QueryCachePutManager.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManager.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/caching/QueryCachePutManager.java index 118bb1dcd8..f880840380 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManager.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/QueryCachePutManager.java @@ -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.sql.results.internal.caching; +package org.hibernate.sql.results.caching; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerDisabledImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerDisabledImpl.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerDisabledImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerDisabledImpl.java index 31704e9e30..bffc17b1e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerDisabledImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerDisabledImpl.java @@ -4,7 +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.sql.results.internal.caching; +package org.hibernate.sql.results.caching.internal; + +import org.hibernate.sql.results.caching.QueryCachePutManager; /** * QueryCachePutManager implementation for cases where we will not be putting diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerEnabledImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerEnabledImpl.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerEnabledImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerEnabledImpl.java index 9edfe4b2bb..fa631063b7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/QueryCachePutManagerEnabledImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/internal/QueryCachePutManagerEnabledImpl.java @@ -4,13 +4,14 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.caching; +package org.hibernate.sql.results.caching.internal; import java.util.ArrayList; import java.util.List; import org.hibernate.cache.spi.QueryKey; import org.hibernate.cache.spi.QueryResultsCache; +import org.hibernate.sql.results.caching.QueryCachePutManager; /** * QueryCachePutManager implementation for cases where we will be putting diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/package-info.java b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/package-info.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/package-info.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/caching/package-info.java index b2f4fb4d12..666c64a7c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/caching/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/caching/package-info.java @@ -8,4 +8,4 @@ /** * Support for caching of query results */ -package org.hibernate.sql.results.internal.caching; +package org.hibernate.sql.results.caching; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParent.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParent.java similarity index 76% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParent.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParent.java index 5ef8c4409d..3780c1d407 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParent.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParent.java @@ -4,18 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain; +package org.hibernate.sql.results.graph; import java.util.Collections; import java.util.List; import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.query.NavigablePath; -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.spi.FetchableContainer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** @@ -30,7 +25,6 @@ public abstract class AbstractFetchParent implements FetchParent { public AbstractFetchParent(FetchableContainer fetchContainer, NavigablePath navigablePath) { this.fetchContainer = fetchContainer; this.navigablePath = navigablePath; - assert fetchContainer instanceof ManagedMappingType; } protected void afterInitialize(DomainResultCreationState creationState) { @@ -42,18 +36,13 @@ public abstract class AbstractFetchParent implements FetchParent { } @Override - public ManagedMappingType getReferencedMappingType() { - return (ManagedMappingType) getFetchContainer(); + public NavigablePath getNavigablePath() { + return navigablePath; } @Override public JavaTypeDescriptor getResultJavaTypeDescriptor() { - return getReferencedMappingType().getJavaTypeDescriptor(); - } - - @Override - public NavigablePath getNavigablePath() { - return navigablePath; + return fetchContainer.getJavaTypeDescriptor(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParentAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParentAccess.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParentAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParentAccess.java index 1e7e23cb6f..aa6bfcc3bf 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/AbstractFetchParentAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AbstractFetchParentAccess.java @@ -4,14 +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.sql.results.internal.domain; +package org.hibernate.sql.results.graph; import java.util.ArrayList; import java.util.List; import java.util.function.Consumer; -import org.hibernate.sql.results.spi.FetchParentAccess; - /** * @author Steve Ebersole */ diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/AssemblerCreationState.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AssemblerCreationState.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/AssemblerCreationState.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/AssemblerCreationState.java index d01c4a7c60..0ae1357404 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/AssemblerCreationState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/AssemblerCreationState.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import org.hibernate.sql.ast.spi.SqlAstCreationContext; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/BiDirectionalFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/BiDirectionalFetch.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/BiDirectionalFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/BiDirectionalFetch.java index 67a23a084a..efe9623cd7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/BiDirectionalFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/BiDirectionalFetch.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import org.hibernate.query.NavigablePath; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResult.java similarity index 78% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResult.java index 4b77efe2a0..8926d7bbff 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResult.java @@ -4,10 +4,14 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.function.Consumer; +import org.hibernate.sql.results.graph.basic.BasicResultGraphNode; +import org.hibernate.sql.results.graph.instantiation.DynamicInstantiationResult; +import org.hibernate.sql.results.graph.entity.EntityResult; + /** * Represents a result value in the domain query results. Acts as the * producer for the {@link DomainResultAssembler} for this result as well @@ -20,7 +24,7 @@ import java.util.function.Consumer; * QueryResult is distinctly different from a {@link Fetch} and so modeled as * completely separate hierarchy. * - * @see BasicResultMappingNode + * @see BasicResultGraphNode * @see DynamicInstantiationResult * @see EntityResult * @see CollectionResult @@ -29,7 +33,7 @@ import java.util.function.Consumer; * * @author Steve Ebersole */ -public interface DomainResult extends ResultSetMappingNode { +public interface DomainResult extends DomainResultGraphNode { /** * The result-variable (alias) associated with this result. */ diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultAssembler.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultAssembler.java index 2ee043807a..47ee68eda0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultAssembler.java @@ -4,8 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultCreationState.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultCreationState.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java index 3d45213dbd..780cc85347 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DomainResultCreationState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultCreationState.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.List; import org.hibernate.LockMode; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; import org.hibernate.sql.ast.spi.SqlAliasBaseManager; import org.hibernate.sql.ast.spi.SqlAstCreationState; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultSetMappingNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphNode.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultSetMappingNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphNode.java index 0b10937867..1abb7c6bb4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultSetMappingNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphNode.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import org.hibernate.query.NavigablePath; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; @@ -16,7 +16,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; * * @author Steve Ebersole */ -public interface ResultSetMappingNode { +public interface DomainResultGraphNode { // todo (6.0) : result variable (selection alias)? - even fetches can have alias JavaTypeDescriptor getResultJavaTypeDescriptor(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphPrinter.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphPrinter.java new file mode 100644 index 0000000000..17863cb326 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/DomainResultGraphPrinter.java @@ -0,0 +1,110 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph; + +import java.util.List; + +import org.hibernate.internal.util.StringHelper; +import org.hibernate.internal.util.collections.Stack; +import org.hibernate.internal.util.collections.StandardStack; + +import org.jboss.logging.Logger; + +/** + * Printer for DomainResult graphs + * + * todo (6.0) : implement / use this + * + * @author Steve Ebersole + */ +public class DomainResultGraphPrinter { + private static final Logger log = Logger.getLogger( DomainResultGraphPrinter.class ); + + public static void print(List domainResults) { + if ( ! log.isDebugEnabled() ) { + return; + } + + final DomainResultGraphPrinter graphPrinter = new DomainResultGraphPrinter(); + graphPrinter.visitDomainResults( domainResults ); + } + + private final StringBuilder buffer = new StringBuilder( "DomainResult Graph:\n"); + private final Stack fetchParentStack = new StandardStack<>(); + + private DomainResultGraphPrinter() { + } + + private void visitDomainResults(List domainResults) { + for ( int i = 0; i < domainResults.size(); i++ ) { + final DomainResult domainResult = domainResults.get( i ); + // DomainResults should always be the base for a branch + assert fetchParentStack.isEmpty(); + + final boolean lastInBranch = i + 1 == domainResults.size(); + + visitGraphNode( domainResult, lastInBranch ); + } + + log.debug( buffer.toString() ); + } + + private void visitGraphNode(DomainResultGraphNode node, boolean lastInBranch) { + indentLine(); + + if ( lastInBranch ) { + buffer.append( " \\-" ); + } + else { + buffer.append( " +-" ); + } + + buffer.append( node.getClass().getSimpleName() ); + if ( node.getNavigablePath() != null ) { + buffer.append( " [" ) + .append( node.getNavigablePath().getFullPath() ) + .append( "]" ); + } + buffer.append( '\n' ); + + if ( node instanceof FetchParent ) { + visitFetches( (FetchParent) node ); + } + } + + private void visitFetches(FetchParent fetchParent) { + fetchParentStack.push( fetchParent ); + + try { + final int numberOfFetches = fetchParent.getFetches().size(); + + for ( int i = 0; i < numberOfFetches; i++ ) { + final Fetch fetch = fetchParent.getFetches().get( i ); + + final boolean lastInBranch = i + 1 == numberOfFetches; + visitGraphNode( fetch, lastInBranch ); + } + } + finally { + fetchParentStack.pop(); + } + } + + private void indentLine() { + fetchParentStack.visitRootFirst( + fetchParent -> { + final boolean hasSubFetches = ! fetchParent.getFetches().isEmpty(); + if ( hasSubFetches ) { + buffer.append( " | " ); + } + else { + buffer.append( " " ); + } + } + ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetch.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetch.java index 4fd4d451eb..400b0caddf 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetch.java @@ -4,11 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.function.Consumer; -import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.NavigablePath; /** @@ -25,7 +24,7 @@ import org.hibernate.query.NavigablePath; * * @author Steve Ebersole */ -public interface Fetch { +public interface Fetch extends DomainResultGraphNode { /** * Obtain the owner of this fetch. Ultimately used to identify * the thing that "owns" this fetched navigable for the purpose of: diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParent.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParent.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParent.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParent.java index 2a9464c4a6..29768a7d9a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParent.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParent.java @@ -4,11 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.List; -import org.hibernate.metamodel.mapping.MappingType; import org.hibernate.query.NavigablePath; /** @@ -16,7 +15,7 @@ import org.hibernate.query.NavigablePath; * * @author Steve Ebersole */ -public interface FetchParent extends ResultSetMappingNode { +public interface FetchParent extends DomainResultGraphNode { FetchableContainer getReferencedMappingContainer(); /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParentAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParentAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java index 893a58e1d4..8834278558 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchParentAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchParentAccess.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.function.Consumer; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetchable.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetchable.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetchable.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetchable.java index 70b82110ba..27072a54c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Fetchable.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Fetchable.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import org.hibernate.LockMode; import org.hibernate.engine.FetchStrategy; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchableContainer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchableContainer.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchableContainer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchableContainer.java index 4edcaf3912..d53c4e8838 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/FetchableContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/FetchableContainer.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph; import java.util.function.Consumer; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Initializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Initializer.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/Initializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/Initializer.java index a3099ad08b..afc05d409a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/Initializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/Initializer.java @@ -4,8 +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.sql.results.spi; +package org.hibernate.sql.results.graph; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.query.NavigablePath; import org.hibernate.sql.exec.spi.ExecutionContext; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicFetch.java similarity index 79% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicFetch.java index a4c363a3b8..bdcbf659d1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicFetch.java @@ -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.sql.results.internal.domain.basic; +package org.hibernate.sql.results.graph.basic; import java.util.function.Consumer; @@ -12,21 +12,20 @@ import org.hibernate.engine.FetchTiming; import org.hibernate.metamodel.mapping.BasicValuedModelPart; import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.BasicResultMappingNode; -import org.hibernate.sql.results.spi.DomainResultAssembler; -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.FetchParentAccess; -import org.hibernate.sql.results.spi.Fetchable; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +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.FetchParentAccess; +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class BasicFetch implements Fetch, BasicResultMappingNode { +public class BasicFetch implements Fetch, BasicResultGraphNode { private final NavigablePath navigablePath; private final FetchParent fetchParent; private final BasicValuedModelPart valuedMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResult.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResult.java index c324cadd37..d14df6d326 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResult.java @@ -4,23 +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.sql.results.internal.domain.basic; +package org.hibernate.sql.results.graph.basic; import java.util.function.Consumer; import org.hibernate.Internal; +import org.hibernate.sql.results.graph.DomainResult; import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.BasicResultMappingNode; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class BasicResult implements BasicResultMappingNode { +public class BasicResult implements DomainResult, BasicResultGraphNode { private final String resultVariable; private final JavaTypeDescriptor javaTypeDescriptor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResultAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultAssembler.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResultAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultAssembler.java index 6abb0cb67b..39da34cc00 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/basic/BasicResultAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultAssembler.java @@ -4,15 +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.sql.results.internal.domain.basic; +package org.hibernate.sql.results.graph.basic; import org.hibernate.Internal; import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.SqlResultsLogger; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.ResultsLogger; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** @@ -55,7 +55,7 @@ public class BasicResultAssembler implements DomainResultAssembler { JdbcValuesSourceProcessingOptions options) { Object jdbcValue = extractRawValue( rowProcessingState ); - SqlResultsLogger.INSTANCE.debugf( "Extracted JDBC value [%d] - [%s]", valuesArrayPosition, jdbcValue ); + ResultsLogger.INSTANCE.debugf( "Extracted JDBC value [%d] - [%s]", valuesArrayPosition, jdbcValue ); if ( valueConverter != null ) { // the raw value type should be the converter's relational-JTD diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/BasicResultMappingNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultGraphNode.java similarity index 72% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/BasicResultMappingNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultGraphNode.java index b8cb714ca0..55d3a3f3de 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/BasicResultMappingNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/basic/BasicResultGraphNode.java @@ -4,7 +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.sql.results.spi; +package org.hibernate.sql.results.graph.basic; + +import org.hibernate.sql.results.graph.DomainResult; /** * Represent a simple scalar return within a query result. Generally this would be values of basic (String, Integer, @@ -13,5 +15,5 @@ package org.hibernate.sql.results.spi; * @author Steve Ebersole * @author Gail Badner */ -public interface BasicResultMappingNode extends DomainResult { +public interface BasicResultGraphNode extends DomainResult { } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionInitializer.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionInitializer.java index 1eab0bd218..a3f8c9b621 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionInitializer.java @@ -4,10 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph.collection; import org.hibernate.collection.spi.PersistentCollection; -import org.hibernate.metamodel.mapping.ModelPart; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.sql.exec.spi.ExecutionContext; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionLoadingLogger.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionLoadingLogger.java similarity index 76% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionLoadingLogger.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionLoadingLogger.java index 9d1b3afe46..24fda355e8 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionLoadingLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionLoadingLogger.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection; -import org.hibernate.sql.results.SqlResultsLogger; +import org.hibernate.sql.results.ResultsLogger; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; @@ -15,7 +15,7 @@ import org.jboss.logging.Logger; * @author Steve Ebersole */ public interface CollectionLoadingLogger extends BasicLogger { - String LOGGER_NAME = SqlResultsLogger.LOGGER_NAME + "loading.collection"; + String LOGGER_NAME = ResultsLogger.LOGGER_NAME + "loading.collection"; /** * Static access to the logging instance diff --git a/hibernate-core/src/main/java/org/hibernate/loader/internal/Preparable.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionResultGraphNode.java similarity index 58% rename from hibernate-core/src/main/java/org/hibernate/loader/internal/Preparable.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionResultGraphNode.java index a24f0f586a..cd3c49116d 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/internal/Preparable.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/CollectionResultGraphNode.java @@ -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.sql.results.graph.collection; + +import org.hibernate.sql.results.graph.DomainResultGraphNode; /** * @author Steve Ebersole */ -public interface Preparable { - void prepare(); +public interface CollectionResultGraphNode extends DomainResultGraphNode { } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingCollectionEntry.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/LoadingCollectionEntry.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingCollectionEntry.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/LoadingCollectionEntry.java index 2a94047781..810fb548c2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingCollectionEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/LoadingCollectionEntry.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph.collection; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionInitializer.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionInitializer.java index b8b075c1f7..645d828726 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionInitializer.java @@ -4,17 +4,19 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.engine.spi.CollectionKey; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.internal.util.StringHelper; +import org.hibernate.sql.results.graph.collection.CollectionLoadingLogger; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -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.RowProcessingState; +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.jdbc.spi.RowProcessingState; /** * Base support for CollectionInitializer implementations @@ -78,7 +80,7 @@ public abstract class AbstractCollectionInitializer implements CollectionInitial /** * Are the values for performing this initialization present in the current - * {@link org.hibernate.sql.results.spi.JdbcValuesSourceProcessingState}? + * {@link JdbcValuesSourceProcessingState}? * Or should a separate/subsequent select be performed * * todo (6.0) : opportunity for performance gain by batching these selects triggered at the end of processing the JdbcValuesSource diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionResultNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionResultNode.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionResultNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionResultNode.java index faddecaa0c..144f1672a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractCollectionResultNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractCollectionResultNode.java @@ -4,18 +4,17 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.CollectionResultNode; -import org.hibernate.sql.results.spi.DomainResult; +import org.hibernate.sql.results.graph.collection.CollectionResultGraphNode; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public abstract class AbstractCollectionResultNode implements CollectionResultNode { +public abstract class AbstractCollectionResultNode implements CollectionResultGraphNode { private final NavigablePath navigablePath; private final PluralAttributeMapping attributeMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractImmediateCollectionInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractImmediateCollectionInitializer.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractImmediateCollectionInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractImmediateCollectionInitializer.java index 7c55776cac..2b6b8cc279 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/AbstractImmediateCollectionInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/AbstractImmediateCollectionInitializer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionSemantics; @@ -15,15 +15,16 @@ import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.internal.util.StringHelper; +import org.hibernate.sql.results.graph.collection.CollectionLoadingLogger; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.query.NavigablePath; import org.hibernate.sql.exec.spi.ExecutionContext; import org.hibernate.sql.results.internal.LoadingCollectionEntryImpl; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * Base support for CollectionInitializer implementations that represent diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializer.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializer.java index 321fd4fc5a..b3dcbbf03e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializer.java @@ -4,16 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.internal.PersistentArrayHolder; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Chris Cranford diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializerProducer.java similarity index 81% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializerProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializerProducer.java index 9e3bd23644..b91da44a00 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ArrayInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ArrayInitializerProducer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -12,12 +12,12 @@ import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionInitializerProducer; 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.Fetch; -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.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Chris Cranford diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializer.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializer.java index 4745c3c14f..9a66e9ff08 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.internal.PersistentBag; @@ -12,9 +12,9 @@ import org.hibernate.collection.internal.PersistentIdentifierBag; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * Initializer for both {@link PersistentBag} and {@link PersistentIdentifierBag} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializerProducer.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializerProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializerProducer.java index 0add24dbb3..c3a9ffb8be 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/BagInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/BagInitializerProducer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -13,13 +13,12 @@ import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionInitializerProducer; 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.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Fetch; -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.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionDomainResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionDomainResult.java new file mode 100644 index 0000000000..ead82d1e01 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionDomainResult.java @@ -0,0 +1,132 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.collection.internal; + +import java.util.Collections; +import java.util.List; +import java.util.function.Consumer; + +import org.hibernate.LockMode; +import org.hibernate.collection.spi.CollectionInitializerProducer; +import org.hibernate.collection.spi.CollectionSemantics; +import org.hibernate.metamodel.mapping.PluralAttributeMapping; +import org.hibernate.query.NavigablePath; +import org.hibernate.sql.ast.tree.from.TableGroup; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +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.FetchableContainer; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.graph.collection.CollectionResultGraphNode; +import org.hibernate.type.descriptor.java.JavaTypeDescriptor; + +/** + * @author Steve Ebersole + */ +public class CollectionDomainResult implements DomainResult, CollectionResultGraphNode, FetchParent { + private final NavigablePath loadingPath; + private final PluralAttributeMapping loadingAttribute; + + private final String resultVariable; + + private final DomainResult fkResult; + + private final CollectionInitializerProducer initializerProducer; + + public CollectionDomainResult( + NavigablePath loadingPath, + PluralAttributeMapping loadingAttribute, + String resultVariable, + TableGroup tableGroup, + DomainResultCreationState creationState) { + this.loadingPath = loadingPath; + this.loadingAttribute = loadingAttribute; + this.resultVariable = resultVariable; + + fkResult = loadingAttribute.getKeyDescriptor().createDomainResult( + loadingPath, + tableGroup, + creationState + ); + + final CollectionSemantics collectionSemantics = loadingAttribute.getCollectionDescriptor().getCollectionSemantics(); + initializerProducer = collectionSemantics.createInitializerProducer( + loadingPath, + loadingAttribute, + this, + true, + null, + LockMode.READ, + creationState + ); + } + + @Override + public String getResultVariable() { + return resultVariable; + } + + @Override + public JavaTypeDescriptor getResultJavaTypeDescriptor() { + return loadingAttribute.getJavaTypeDescriptor(); + } + + @Override + public DomainResultAssembler createResultAssembler( + Consumer initializerCollector, + AssemblerCreationState creationState) { + + final DomainResultAssembler fkAssembler = fkResult.createResultAssembler( + initializerCollector, + creationState + ); + + final CollectionInitializer initializer = initializerProducer.produceInitializer( + loadingPath, + loadingAttribute, + null, + LockMode.READ, + fkAssembler, + fkAssembler, + initializerCollector, + creationState + ); + + initializerCollector.accept( initializer ); + + return new EagerCollectionAssembler( loadingAttribute, initializer ); + } + + @Override + public FetchableContainer getReferencedMappingContainer() { + return loadingAttribute; + } + + @Override + public FetchableContainer getReferencedMappingType() { + return getReferencedMappingContainer(); + } + + @Override + public NavigablePath getNavigablePath() { + return loadingPath; + } + + @Override + public List getFetches() { + return Collections.emptyList(); + } + + @Override + public Fetch findFetch(String fetchableName) { + return null; + } + +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionFetch.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionFetch.java index 5ff5bf5ed2..e366290605 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/CollectionFetch.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.FetchParent; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParent; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionAssembler.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionAssembler.java index 1b7b5eaf9c..274a3c19e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionAssembler.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -16,14 +16,14 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.persister.collection.CollectionPersister; 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.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; -import org.hibernate.sql.results.spi.RowProcessingState; +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; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionFetch.java similarity index 65% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionFetch.java index e5ebc14832..fca30b18a3 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionFetch.java @@ -4,17 +4,18 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParent; -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.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole @@ -41,4 +42,9 @@ public class DelayedCollectionFetch extends CollectionFetch { creationState ); } + + @Override + public JavaTypeDescriptor getResultJavaTypeDescriptor() { + return getFetchedMapping().getJavaTypeDescriptor(); + } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionInitializer.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionInitializer.java index 5e031eb28f..45535ed59e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/DelayedCollectionInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/DelayedCollectionInitializer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.collection.spi.CollectionSemantics; import org.hibernate.collection.spi.PersistentCollection; @@ -16,9 +16,9 @@ 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.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionAssembler.java similarity index 76% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionAssembler.java index 16ae2be9a7..6c2980aa90 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionAssembler.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.metamodel.mapping.PluralAttributeMapping; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionFetch.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionFetch.java index baaddec0c9..a48f215bd1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EagerCollectionFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EagerCollectionFetch.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.List; import java.util.function.Consumer; @@ -18,16 +18,16 @@ import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.tree.from.TableGroup; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -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.FetchParentAccess; -import org.hibernate.sql.results.spi.FetchableContainer; -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.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +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.FetchParentAccess; +import org.hibernate.sql.results.graph.FetchableContainer; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EntityCollectionPartTableGroup.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EntityCollectionPartTableGroup.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java index 1cb90d748e..434cc3e67d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/EntityCollectionPartTableGroup.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/EntityCollectionPartTableGroup.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.List; import java.util.Set; @@ -12,10 +12,9 @@ import java.util.function.Consumer; import java.util.function.Supplier; import org.hibernate.LockMode; -import org.hibernate.metamodel.mapping.ModelPartContainer; import org.hibernate.metamodel.mapping.internal.EntityCollectionPart; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.tree.from.TableGroup; import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.from.TableReference; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializer.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializer.java index 45f018f275..c674d0bce7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializer.java @@ -4,16 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.internal.PersistentList; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * CollectionInitializer for PersistentList loading diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializerProducer.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializerProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializerProducer.java index 2963fb2593..3e98d79c5d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/ListInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/ListInitializerProducer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -12,13 +12,12 @@ import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionInitializerProducer; 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.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Fetch; -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.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializer.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializer.java index 76c587ee81..ce0a06e31e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializer.java @@ -4,16 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.internal.PersistentMap; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * Represents an immediate initialization of some sort (join, select, batch, sub-select) diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializerProducer.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializerProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializerProducer.java index 265fba04e5..00196a9a26 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/MapInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/MapInitializerProducer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -12,12 +12,12 @@ import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionInitializerProducer; 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.Fetch; -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.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/PluralAttributeAssemblerImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/PluralAttributeAssemblerImpl.java similarity index 76% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/PluralAttributeAssemblerImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/PluralAttributeAssemblerImpl.java index 0724e02a2a..9f3b930032 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/PluralAttributeAssemblerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/PluralAttributeAssemblerImpl.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.collection.spi.PersistentCollection; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializer.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializer.java index f8712cac1b..910d13f8e7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializer.java @@ -4,16 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import org.hibernate.LockMode; import org.hibernate.collection.internal.PersistentSet; import org.hibernate.internal.log.LoggingHelper; import org.hibernate.metamodel.mapping.PluralAttributeMapping; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializerProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializerProducer.java similarity index 78% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializerProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializerProducer.java index 60604add0a..2dd92428bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/SetInitializerProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/collection/internal/SetInitializerProducer.java @@ -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.sql.results.internal.domain.collection; +package org.hibernate.sql.results.graph.collection.internal; import java.util.function.Consumer; @@ -12,13 +12,12 @@ import org.hibernate.LockMode; import org.hibernate.collection.spi.CollectionInitializerProducer; 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.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Fetch; -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.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/AbstractCompositeInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/AbstractCompositeInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java index 5947fc4446..bfcd7e49e4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/AbstractCompositeInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/AbstractEmbeddableInitializer.java @@ -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.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable; import java.util.IdentityHashMap; import java.util.Map; @@ -15,20 +15,18 @@ import org.hibernate.metamodel.mapping.SingularAttributeMapping; import org.hibernate.metamodel.mapping.StateArrayContributorMapping; import org.hibernate.query.NavigablePath; import org.hibernate.sql.results.internal.NullValueAssembler; -import org.hibernate.sql.results.internal.domain.AbstractFetchParentAccess; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CompositeInitializer; -import org.hibernate.sql.results.spi.CompositeResultNode; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.AbstractFetchParentAccess; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Steve Ebersole */ -public abstract class AbstractCompositeInitializer extends AbstractFetchParentAccess implements CompositeInitializer { +public abstract class AbstractEmbeddableInitializer extends AbstractFetchParentAccess implements EmbeddableInitializer { private final NavigablePath navigablePath; private final EmbeddableValuedModelPart embeddedModelPartDescriptor; private final FetchParentAccess fetchParentAccess; @@ -41,8 +39,8 @@ public abstract class AbstractCompositeInitializer extends AbstractFetchParentAc @SuppressWarnings("WeakerAccess") - public AbstractCompositeInitializer( - CompositeResultNode resultDescriptor, + public AbstractEmbeddableInitializer( + EmbeddableResultGraphNode resultDescriptor, FetchParentAccess fetchParentAccess, Consumer initializerConsumer, AssemblerCreationState creationState) { @@ -120,7 +118,7 @@ public abstract class AbstractCompositeInitializer extends AbstractFetchParentAc .getRepresentationStrategy() .getInstantiator() .instantiate( rowProcessingState.getSession() ); - CompositeLoadingLogger.INSTANCE.debugf( + EmbeddableLoadingLogger.INSTANCE.debugf( "Created composite instance [%s] : %s", navigablePath, compositeInstance @@ -130,7 +128,7 @@ public abstract class AbstractCompositeInitializer extends AbstractFetchParentAc @Override public void initializeInstance(RowProcessingState rowProcessingState) { - CompositeLoadingLogger.INSTANCE.debugf( + EmbeddableLoadingLogger.INSTANCE.debugf( "Initializing composite instance [%s] : %s", navigablePath, compositeInstance diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableInitializer.java similarity index 71% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableInitializer.java index f19378960b..854314ec59 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableInitializer.java @@ -4,15 +4,17 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph.embeddable; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; /** * @author Steve Ebersole */ -public interface CompositeInitializer extends Initializer, FetchParentAccess { +public interface EmbeddableInitializer extends Initializer, FetchParentAccess { @Override EmbeddableValuedModelPart getInitializedPart(); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeLoadingLogger.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableLoadingLogger.java similarity index 69% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeLoadingLogger.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableLoadingLogger.java index 6803c2c11d..f7a680d791 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeLoadingLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableLoadingLogger.java @@ -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.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable; -import org.hibernate.sql.results.SqlResultsLogger; +import org.hibernate.sql.results.ResultsLogger; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; @@ -18,14 +18,14 @@ import org.jboss.logging.annotations.ValidIdRange; */ @MessageLogger( projectCode = "HHH" ) @ValidIdRange( min = 90005301, max = 90005400 ) -public interface CompositeLoadingLogger extends BasicLogger { - String LOGGER_NAME = SqlResultsLogger.LOGGER_NAME + "loading.composite"; +public interface EmbeddableLoadingLogger extends BasicLogger { + String LOGGER_NAME = ResultsLogger.LOGGER_NAME + "loading.composite"; /** * Static access to the logging instance */ - CompositeLoadingLogger INSTANCE = Logger.getMessageLogger( - CompositeLoadingLogger.class, + EmbeddableLoadingLogger INSTANCE = Logger.getMessageLogger( + EmbeddableLoadingLogger.class, LOGGER_NAME ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeResultNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableResultGraphNode.java similarity index 71% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeResultNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableResultGraphNode.java index 77585e3a73..05cb89848e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CompositeResultNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableResultGraphNode.java @@ -4,17 +4,18 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph.embeddable; +import org.hibernate.sql.results.graph.DomainResultGraphNode; +import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; -import org.hibernate.metamodel.mapping.ManagedMappingType; import org.hibernate.query.NavigablePath; /** * @author Steve Ebersole */ -public interface CompositeResultNode extends ResultSetMappingNode, FetchParent { +public interface EmbeddableResultGraphNode extends DomainResultGraphNode, FetchParent { @Override default NavigablePath getNavigablePath() { return null; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableValuedFetchable.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableValuedFetchable.java new file mode 100644 index 0000000000..6f6d320235 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/EmbeddableValuedFetchable.java @@ -0,0 +1,16 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.embeddable; + +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; + +/** + * @author Steve Ebersole + */ +public interface EmbeddableValuedFetchable extends EmbeddableValuedModelPart, Fetchable { +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableAssembler.java similarity index 56% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableAssembler.java index 0bb0f713fd..75c83bc85a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableAssembler.java @@ -4,22 +4,22 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable.internal; -import org.hibernate.sql.results.spi.CompositeInitializer; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.embeddable.EmbeddableInitializer; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class CompositeAssembler implements DomainResultAssembler { - private final CompositeInitializer initializer; +public class EmbeddableAssembler implements DomainResultAssembler { + private final EmbeddableInitializer initializer; - public CompositeAssembler(CompositeInitializer initializer) { + public EmbeddableAssembler(EmbeddableInitializer initializer) { this.initializer = initializer; } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchImpl.java similarity index 72% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchImpl.java index 763c0b716f..de79cdd70d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchImpl.java @@ -4,39 +4,40 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable.internal; import java.util.function.Consumer; import org.hibernate.LockMode; import org.hibernate.engine.FetchTiming; +import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable; import org.hibernate.metamodel.mapping.EmbeddableMappingType; import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.JoinType; import org.hibernate.sql.ast.tree.from.TableGroupJoin; -import org.hibernate.sql.results.internal.domain.AbstractFetchParent; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CompositeResultNode; -import org.hibernate.sql.results.spi.DomainResultAssembler; -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.FetchParentAccess; -import org.hibernate.sql.results.spi.Fetchable; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AbstractFetchParent; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; +import org.hibernate.sql.results.graph.DomainResultAssembler; +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.FetchParentAccess; +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole */ -public class CompositeFetch extends AbstractFetchParent implements CompositeResultNode, Fetch { +public class EmbeddableFetchImpl extends AbstractFetchParent implements EmbeddableResultGraphNode, Fetch { private final FetchParent fetchParent; private final FetchTiming fetchTiming; private final boolean nullable; - public CompositeFetch( + public EmbeddableFetchImpl( NavigablePath navigablePath, - EmbeddableValuedModelPart embeddedPartDescriptor, + EmbeddableValuedFetchable embeddedPartDescriptor, FetchParent fetchParent, FetchTiming fetchTiming, boolean nullable, @@ -106,7 +107,7 @@ public class CompositeFetch extends AbstractFetchParent implements CompositeResu FetchParentAccess parentAccess, Consumer collector, AssemblerCreationState creationState) { - final CompositeFetchInitializer initializer = new CompositeFetchInitializer( + final EmbeddableFetchInitializer initializer = new EmbeddableFetchInitializer( parentAccess, this, collector, @@ -116,6 +117,6 @@ public class CompositeFetch extends AbstractFetchParent implements CompositeResu collector.accept( initializer ); - return new CompositeAssembler( initializer ); + return new EmbeddableAssembler( initializer ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java new file mode 100644 index 0000000000..debb90561a --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableFetchInitializer.java @@ -0,0 +1,36 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.embeddable.internal; + +import java.util.function.Consumer; + +import org.hibernate.sql.results.graph.embeddable.AbstractEmbeddableInitializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.embeddable.EmbeddableInitializer; +import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; + +/** + * @author Steve Ebersole + */ +public class EmbeddableFetchInitializer + extends AbstractEmbeddableInitializer + implements EmbeddableInitializer { + public EmbeddableFetchInitializer( + FetchParentAccess fetchParentAccess, + EmbeddableResultGraphNode resultDescriptor, + Consumer initializerConsumer, + AssemblerCreationState creationState) { + super( resultDescriptor, fetchParentAccess, initializerConsumer, creationState ); + } + + @Override + public Object getParentKey() { + return getFetchParentAccess().getParentKey(); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultImpl.java similarity index 77% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultImpl.java index d02262931c..442372bfe1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultImpl.java @@ -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.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable.internal; import java.util.function.Consumer; @@ -15,22 +15,22 @@ import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.JoinType; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.tree.from.TableGroupJoin; -import org.hibernate.sql.results.internal.domain.AbstractFetchParent; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CompositeResultNode; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AbstractFetchParent; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class CompositeResult extends AbstractFetchParent implements CompositeResultNode, DomainResult { +public class EmbeddableResultImpl extends AbstractFetchParent implements EmbeddableResultGraphNode, DomainResult { private final String resultVariable; - public CompositeResult( + public EmbeddableResultImpl( NavigablePath navigablePath, EmbeddableValuedModelPart modelPart, String resultVariable, @@ -91,7 +91,7 @@ public class CompositeResult extends AbstractFetchParent implements Composite public DomainResultAssembler createResultAssembler( Consumer initializerCollector, AssemblerCreationState creationState) { - final CompositeRootInitializer initializer = new CompositeRootInitializer( + final EmbeddableResultInitializer initializer = new EmbeddableResultInitializer( this, initializerCollector, creationState @@ -100,6 +100,6 @@ public class CompositeResult extends AbstractFetchParent implements Composite initializerCollector.accept( initializer ); //noinspection unchecked - return new CompositeAssembler( initializer ); + return new EmbeddableAssembler( initializer ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeRootInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java similarity index 51% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeRootInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java index 50f0dc9609..f91d7fb5c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeRootInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/embeddable/internal/EmbeddableResultInitializer.java @@ -4,20 +4,21 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.composite; +package org.hibernate.sql.results.graph.embeddable.internal; import java.util.function.Consumer; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CompositeResultNode; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.embeddable.AbstractEmbeddableInitializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.embeddable.EmbeddableResultGraphNode; +import org.hibernate.sql.results.graph.Initializer; /** * @author Steve Ebersole */ -public class CompositeRootInitializer extends AbstractCompositeInitializer { - public CompositeRootInitializer( - CompositeResultNode resultDescriptor, +public class EmbeddableResultInitializer extends AbstractEmbeddableInitializer { + public EmbeddableResultInitializer( + EmbeddableResultGraphNode resultDescriptor, Consumer initializerConsumer, AssemblerCreationState creationState) { super( resultDescriptor, null, initializerConsumer, creationState ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java index a274b9deea..9cf3db4f84 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityInitializer.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity; import java.io.Serializable; import java.util.ArrayList; @@ -39,16 +39,13 @@ import org.hibernate.persister.entity.Loadable; import org.hibernate.proxy.HibernateProxy; import org.hibernate.query.NavigablePath; import org.hibernate.sql.results.internal.NullValueAssembler; -import org.hibernate.sql.results.internal.domain.AbstractFetchParentAccess; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.EntityResultNode; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.LoadingEntityEntry; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.AbstractFetchParentAccess; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.TypeHelper; import static org.hibernate.internal.log.LoggingHelper.toLoggableString; @@ -89,7 +86,7 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces @SuppressWarnings("WeakerAccess") protected AbstractEntityInitializer( - EntityResultNode resultDescriptor, + EntityResultGraphNode resultDescriptor, NavigablePath navigablePath, LockMode lockMode, DomainResult identifierResult, diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityResultNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityResultGraphNode.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityResultNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityResultGraphNode.java index e19b00ed67..a2dbdaf8a2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityResultNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractEntityResultGraphNode.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity; import org.hibernate.LockMode; import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping; @@ -14,16 +14,17 @@ import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.metamodel.mapping.EntityVersionMapping; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.tree.from.TableGroup; -import org.hibernate.sql.results.internal.domain.AbstractFetchParent; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.sql.results.spi.EntityResultNode; +import org.hibernate.sql.results.graph.AbstractFetchParent; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultCreationState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** + * AbstractFetchParent sub-class for entity-valued graph nodes + * * @author Steve Ebersole */ -public abstract class AbstractEntityResultNode extends AbstractFetchParent implements EntityResultNode { +public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent implements EntityResultGraphNode { private final EntityValuedModelPart referencedModelPart; private final DomainResult identifierResult; private final DomainResult discriminatorResult; @@ -32,8 +33,7 @@ public abstract class AbstractEntityResultNode extends AbstractFetchParent imple private final EntityMappingType targetType; - @SuppressWarnings("WeakerAccess") - public AbstractEntityResultNode( + public AbstractEntityResultGraphNode( EntityValuedModelPart referencedModelPart, LockMode lockMode, NavigablePath navigablePath, @@ -42,7 +42,7 @@ public abstract class AbstractEntityResultNode extends AbstractFetchParent imple } @SuppressWarnings("WeakerAccess") - public AbstractEntityResultNode( + public AbstractEntityResultGraphNode( EntityValuedModelPart referencedModelPart, LockMode lockMode, NavigablePath navigablePath, @@ -98,8 +98,8 @@ public abstract class AbstractEntityResultNode extends AbstractFetchParent imple } @Override - public EntityValuedModelPart getReferencedMappingContainer() { - return getEntityValuedModelPart(); + public EntityMappingType getReferencedMappingContainer() { + return getEntityValuedModelPart().getEntityMappingType(); } @Override @@ -116,18 +116,15 @@ public abstract class AbstractEntityResultNode extends AbstractFetchParent imple return lockMode; } - @SuppressWarnings("WeakerAccess") - protected DomainResult getIdentifierResult() { + public DomainResult getIdentifierResult() { return identifierResult; } - @SuppressWarnings("WeakerAccess") - protected DomainResult getDiscriminatorResult() { + public DomainResult getDiscriminatorResult() { return discriminatorResult; } - @SuppressWarnings("WeakerAccess") - protected DomainResult getVersionResult() { + public DomainResult getVersionResult() { return versionResult; } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java new file mode 100644 index 0000000000..bd58871666 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/AbstractNonLazyEntityFetch.java @@ -0,0 +1,88 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.entity; + +import java.util.function.Consumer; + +import org.hibernate.LockMode; +import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.query.NavigablePath; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.graph.entity.internal.EntityAssembler; + +/** + * Support for non-lazy EntityFetch implementations - both joined and subsequent-select + * + * @author Andrea Boriero + */ +public abstract class AbstractNonLazyEntityFetch extends AbstractEntityResultGraphNode implements EntityFetch { + private final FetchParent fetchParent; + private final boolean nullable; + + public AbstractNonLazyEntityFetch( + FetchParent fetchParent, + EntityValuedModelPart fetchedPart, + NavigablePath navigablePath, + boolean nullable, + LockMode lockMode, + DomainResultCreationState creationState) { + super( fetchedPart, lockMode, navigablePath, creationState ); + this.fetchParent = fetchParent; + this.nullable = nullable; + } + + @Override + public EntityMappingType getReferencedMappingType() { + return getEntityValuedModelPart().getEntityMappingType(); + } + + @Override + public EntityMappingType getReferencedMappingContainer() { + return getEntityValuedModelPart().getEntityMappingType(); + } + + @Override + public FetchParent getFetchParent() { + return fetchParent; + } + + @Override + public Fetchable getFetchedMapping() { + return (Fetchable) getEntityValuedModelPart(); + } + + @Override + public boolean isNullable() { + return nullable; + } + + @Override + public DomainResultAssembler createAssembler( + FetchParentAccess parentAccess, + Consumer collector, + AssemblerCreationState creationState) { + final EntityInitializer entityInitializer = getEntityInitializer( + parentAccess, + collector, + creationState + ); + collector.accept( entityInitializer ); + return new EntityAssembler( getFetchedMapping().getJavaTypeDescriptor(), entityInitializer ); + } + + protected abstract EntityInitializer getEntityInitializer( + FetchParentAccess parentAccess, + Consumer collector, + AssemblerCreationState creationState); +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionResultNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityFetch.java similarity index 62% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionResultNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityFetch.java index 961258af21..f1b8834424 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CollectionResultNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityFetch.java @@ -4,10 +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.sql.results.spi; +package org.hibernate.sql.results.graph.entity; + +import org.hibernate.sql.results.graph.Fetch; /** * @author Steve Ebersole */ -public interface CollectionResultNode extends ResultSetMappingNode { +public interface EntityFetch extends EntityResultGraphNode, Fetch { } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityInitializer.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityInitializer.java index 5fc0933bf3..e7e47d15de 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityInitializer.java @@ -4,8 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph.entity; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.persister.entity.EntityPersister; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityLoadingLogger.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityLoadingLogger.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityLoadingLogger.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityLoadingLogger.java index 10b5a95e13..85c208d429 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityLoadingLogger.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityLoadingLogger.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity; -import org.hibernate.sql.results.SqlResultsLogger; +import org.hibernate.sql.results.ResultsLogger; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; @@ -19,7 +19,7 @@ import org.jboss.logging.annotations.ValidIdRange; @MessageLogger( projectCode = "HHH" ) @ValidIdRange( min = 90005201, max = 90005300 ) public interface EntityLoadingLogger extends BasicLogger { - String LOGGER_NAME = SqlResultsLogger.LOGGER_NAME + "loading.entity"; + String LOGGER_NAME = ResultsLogger.LOGGER_NAME + "loading.entity"; /** * Static access to the logging instance diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResult.java similarity index 59% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResult.java index 08f384d374..71f350bd03 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResult.java @@ -4,16 +4,14 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.graph.entity; -import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.sql.results.graph.DomainResult; /** * Further defines a first-level Return that is a reference to an entity * * @author Steve Ebersole */ -public interface EntityResult extends EntityResultNode, DomainResult { - @Override - EntityValuedModelPart getReferencedMappingContainer(); +public interface EntityResult extends EntityResultGraphNode, DomainResult { } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResultNode.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResultGraphNode.java similarity index 65% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResultNode.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResultGraphNode.java index 48aeb777c1..8337dbeb67 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/EntityResultNode.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityResultGraphNode.java @@ -4,8 +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.sql.results.spi; +package org.hibernate.sql.results.graph.entity; +import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.sql.results.graph.DomainResultGraphNode; +import org.hibernate.sql.results.graph.FetchParent; import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.query.NavigablePath; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; @@ -15,7 +18,7 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; * * @author Steve Ebersole */ -public interface EntityResultNode extends ResultSetMappingNode, FetchParent { +public interface EntityResultGraphNode extends DomainResultGraphNode, FetchParent { @Override NavigablePath getNavigablePath(); @@ -27,7 +30,7 @@ public interface EntityResultNode extends ResultSetMappingNode, FetchParent { } @Override - default EntityValuedModelPart getReferencedMappingContainer() { - return getEntityValuedModelPart(); + default EntityMappingType getReferencedMappingContainer() { + return getEntityValuedModelPart().getEntityMappingType(); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityValuedFetchable.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityValuedFetchable.java new file mode 100644 index 0000000000..df8d5d284d --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/EntityValuedFetchable.java @@ -0,0 +1,30 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.entity; + +import org.hibernate.LockMode; +import org.hibernate.engine.FetchTiming; +import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.query.NavigablePath; + +/** + * @author Steve Ebersole + */ +public interface EntityValuedFetchable extends Fetchable, EntityValuedModelPart { + @Override + EntityFetch generateFetch( + FetchParent fetchParent, + NavigablePath fetchablePath, + FetchTiming fetchTiming, + boolean selected, + LockMode lockMode, + String resultVariable, + DomainResultCreationState creationState); +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingEntityEntry.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/LoadingEntityEntry.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingEntityEntry.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/LoadingEntityEntry.java index 30f29e47a6..1577574608 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadingEntityEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/LoadingEntityEntry.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.graph.entity; import java.util.Locale; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/AbstractNonJoinedEntityFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/AbstractNonJoinedEntityFetch.java new file mode 100644 index 0000000000..b0c073e1ba --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/AbstractNonJoinedEntityFetch.java @@ -0,0 +1,73 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.entity.internal; + +import java.util.Collections; +import java.util.List; + +import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.query.NavigablePath; +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.entity.EntityFetch; +import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; + +/** + * @author Steve Ebersole + */ +public abstract class AbstractNonJoinedEntityFetch implements EntityFetch { + private final NavigablePath navigablePath; + private final EntityValuedFetchable fetchedModelPart; + private final FetchParent fetchParent; + + public AbstractNonJoinedEntityFetch( + NavigablePath navigablePath, + EntityValuedFetchable fetchedModelPart, + FetchParent fetchParent) { + this.navigablePath = navigablePath; + this.fetchedModelPart = fetchedModelPart; + this.fetchParent = fetchParent; + } + + @Override + public NavigablePath getNavigablePath() { + return navigablePath; + } + + @Override + public EntityValuedFetchable getFetchedMapping() { + return fetchedModelPart; + } + + @Override + public EntityValuedFetchable getEntityValuedModelPart() { + return fetchedModelPart; + } + + @Override + public FetchParent getFetchParent() { + return fetchParent; + } + + @Override + public List getFetches() { + return Collections.emptyList(); + } + + @Override + public Fetch findFetch(String fetchableName) { + return null; + } + + @Override + public EntityMappingType getReferencedMappingType() { + return fetchedModelPart.getEntityMappingType(); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityAssembler.java similarity index 74% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityAssembler.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityAssembler.java index 747c84b93f..006cf5ade5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityAssembler.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.entity.EntityInitializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedImpl.java new file mode 100644 index 0000000000..0542631f28 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedImpl.java @@ -0,0 +1,64 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.entity.internal; + +import java.util.function.Consumer; + +import org.hibernate.LockMode; +import org.hibernate.metamodel.mapping.internal.SingularAssociationAttributeMapping; +import org.hibernate.query.NavigablePath; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.graph.entity.EntityInitializer; + +/** + * @author Andrea Boriero + * @author Steve Ebersole + */ +public class EntityFetchDelayedImpl extends AbstractNonJoinedEntityFetch { + private final LockMode lockMode; + private final boolean nullable; + + private final DomainResult keyResult; + + public EntityFetchDelayedImpl( + FetchParent fetchParent, + SingularAssociationAttributeMapping fetchedAttribute, + LockMode lockMode, + boolean nullable, + NavigablePath navigablePath, + DomainResult keyResult) { + super( navigablePath, fetchedAttribute, fetchParent ); + this.lockMode = lockMode; + this.nullable = nullable; + + this.keyResult = keyResult; + } + + @Override + public boolean isNullable() { + return nullable; + } + + @Override + public DomainResultAssembler createAssembler( + FetchParentAccess parentAccess, + Consumer collector, + AssemblerCreationState creationState) { + final EntityInitializer entityInitializer = new EntityFetchDelayedInitializer( + getNavigablePath(), + getEntityValuedModelPart().getEntityMappingType().getEntityPersister(), + keyResult.createResultAssembler( collector, creationState ) + ); + collector.accept( entityInitializer ); + return new EntityAssembler( getFetchedMapping().getJavaTypeDescriptor(), entityInitializer ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedInitializer.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedInitializer.java index 23e8744e59..ea6876ccb7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchDelayedInitializer.java @@ -4,23 +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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.internal.domain.AbstractFetchParentAccess; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.AbstractFetchParentAccess; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.entity.EntityInitializer; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Andrea Boriero * @author Steve Ebersole */ -public class DelayedEntityFetchInitializer extends AbstractFetchParentAccess implements EntityInitializer { +public class EntityFetchDelayedInitializer extends AbstractFetchParentAccess implements EntityInitializer { private final NavigablePath navigablePath; private final EntityPersister concreteDescriptor; @@ -29,7 +29,7 @@ public class DelayedEntityFetchInitializer extends AbstractFetchParentAccess imp private Object entityInstance; private Object identifier; - protected DelayedEntityFetchInitializer( + protected EntityFetchDelayedInitializer( NavigablePath fetchedNavigable, EntityPersister concreteDescriptor, DomainResultAssembler identifierAssembler) { diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java similarity index 59% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetch.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java index f8d1b80b18..cb6d97cf9c 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetch.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchJoinedImpl.java @@ -4,41 +4,41 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; import org.hibernate.LockMode; -import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.sql.results.graph.entity.AbstractNonLazyEntityFetch; +import org.hibernate.sql.results.graph.entity.EntityInitializer; +import org.hibernate.sql.results.graph.entity.EntityValuedFetchable; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.FetchParent; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Fetchable; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; /** * @author Andrea Boriero * @author Steve Ebersole */ -public class EntityFetch extends AbstractEntityFetch { +public class EntityFetchJoinedImpl extends AbstractNonLazyEntityFetch { private final EntityResultImpl entityResult; - public EntityFetch( + public EntityFetchJoinedImpl( FetchParent fetchParent, - Fetchable fetchedAttribute, + EntityValuedFetchable fetchedAttribute, LockMode lockMode, boolean nullable, NavigablePath navigablePath, DomainResultCreationState creationState) { - super( fetchParent, fetchedAttribute, navigablePath, nullable, lockMode ); + super( fetchParent, fetchedAttribute, navigablePath, nullable, lockMode, creationState ); entityResult = new EntityResultImpl( navigablePath, - (EntityValuedModelPart) fetchedAttribute, + fetchedAttribute, null, creationState ); @@ -49,7 +49,7 @@ public class EntityFetch extends AbstractEntityFetch { FetchParentAccess parentAccess, Consumer collector, AssemblerCreationState creationState) { - return new EntityFetchInitializer( + return new EntityInitializerJoinedFetch( entityResult, getNavigablePath(), getLockMode(), diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchSelectImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchSelectImpl.java new file mode 100644 index 0000000000..08dc615bc6 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityFetchSelectImpl.java @@ -0,0 +1,68 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * License: GNU Lesser General Public License (LGPL), version 2.1 or later + * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html + */ +package org.hibernate.sql.results.graph.entity.internal; + +import java.util.function.Consumer; + +import org.hibernate.LockMode; +import org.hibernate.metamodel.mapping.internal.SingularAssociationAttributeMapping; +import org.hibernate.query.NavigablePath; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultCreationState; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.FetchParentAccess; +import org.hibernate.sql.results.graph.Initializer; + +/** + * An eager entity fetch performed as a subsequent (n+1) select + * + * @author Andrea Boriero + */ +public class EntityFetchSelectImpl extends AbstractNonJoinedEntityFetch { + private final boolean nullable; + private final DomainResult result; + + public EntityFetchSelectImpl( + FetchParent fetchParent, + SingularAssociationAttributeMapping fetchedAttribute, + LockMode lockMode, + boolean nullable, + NavigablePath navigablePath, + DomainResult result, + DomainResultCreationState creationState) { + super( navigablePath, fetchedAttribute, fetchParent ); + this.nullable = nullable; + this.result = result; + } + + @Override + public boolean isNullable() { + return nullable; + } + + @Override + public DomainResultAssembler createAssembler( + FetchParentAccess parentAccess, + Consumer collector, + AssemblerCreationState creationState) { + final EntityInitializerSelectFetch initializer = new EntityInitializerSelectFetch( + getNavigablePath(), + getReferencedMappingContainer().getEntityPersister(), + result.createResultAssembler( collector, creationState ), + nullable + ); + + collector.accept( initializer ); + + return new EntityAssembler( + getResultJavaTypeDescriptor(), + initializer + ); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerJoinedFetch.java similarity index 66% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetchInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerJoinedFetch.java index 45c4baa149..315b79112f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityFetchInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerJoinedFetch.java @@ -4,24 +4,25 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; import org.hibernate.LockMode; import org.hibernate.internal.log.LoggingHelper; +import org.hibernate.sql.results.graph.entity.AbstractEntityInitializer; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.EntityResultNode; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.entity.EntityResultGraphNode; +import org.hibernate.sql.results.graph.Initializer; /** * @author Andrea Boriero */ -public class EntityFetchInitializer extends AbstractEntityInitializer { - protected EntityFetchInitializer( - EntityResultNode resultDescriptor, +public class EntityInitializerJoinedFetch extends AbstractEntityInitializer { + protected EntityInitializerJoinedFetch( + EntityResultGraphNode resultDescriptor, NavigablePath navigablePath, LockMode lockMode, DomainResult identifierResult, diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerSelectFetch.java similarity index 77% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerSelectFetch.java index fd54da6938..754779945b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityInitializerSelectFetch.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; @@ -13,35 +13,33 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.proxy.HibernateProxy; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.internal.domain.AbstractFetchParentAccess; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.AbstractFetchParentAccess; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.entity.EntityInitializer; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Andrea Boriero */ -public class SelectEntityInitializer extends AbstractFetchParentAccess implements EntityInitializer { - +public class EntityInitializerSelectFetch extends AbstractFetchParentAccess implements EntityInitializer { private final NavigablePath navigablePath; private final EntityPersister concreteDescriptor; private final DomainResultAssembler identifierAssembler; - private final boolean unwrapProxy; + private final boolean isEnhancedForLazyLoading; private final boolean nullable; private Object entityInstance; - protected SelectEntityInitializer( + protected EntityInitializerSelectFetch( NavigablePath fetchedNavigable, EntityPersister concreteDescriptor, DomainResultAssembler identifierAssembler, - boolean unwrapProxy, boolean nullable) { this.navigablePath = fetchedNavigable; this.concreteDescriptor = concreteDescriptor; this.identifierAssembler = identifierAssembler; - this.unwrapProxy = unwrapProxy; this.nullable = nullable; + this.isEnhancedForLazyLoading = concreteDescriptor.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading(); } @Override @@ -80,10 +78,8 @@ public class SelectEntityInitializer extends AbstractFetchParentAccess implement nullable ); - if ( entityInstance instanceof HibernateProxy ) { - final boolean isProxyUnwrapEnabled = unwrapProxy && concreteDescriptor.isInstrumented(); - - ( (HibernateProxy) entityInstance ).getHibernateLazyInitializer().setUnwrap( isProxyUnwrapEnabled ); + if ( entityInstance instanceof HibernateProxy && isEnhancedForLazyLoading ) { + ( (HibernateProxy) entityInstance ).getHibernateLazyInitializer().setUnwrap( true ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityResultImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultImpl.java similarity index 71% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityResultImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultImpl.java index 4adad9b390..84bb765673 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityResultImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultImpl.java @@ -4,25 +4,26 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; +import org.hibernate.sql.results.graph.FetchableContainer; +import org.hibernate.sql.results.graph.entity.AbstractEntityResultGraphNode; +import org.hibernate.sql.results.graph.entity.EntityResult; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.DomainResultCreationState; - -import org.hibernate.sql.results.spi.EntityResult; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * Standard ReturnEntity impl * * @author Steve Ebersole */ -public class EntityResultImpl extends AbstractEntityResultNode implements EntityResult { +public class EntityResultImpl extends AbstractEntityResultGraphNode implements EntityResult { private final String resultVariable; public EntityResultImpl( @@ -51,6 +52,11 @@ public class EntityResultImpl extends AbstractEntityResultNode implements Entity afterInitialize( creationState ); } + @Override + public FetchableContainer getReferencedMappingType() { + return getReferencedMappingContainer(); + } + @Override public String getResultVariable() { return resultVariable; @@ -62,7 +68,7 @@ public class EntityResultImpl extends AbstractEntityResultNode implements Entity AssemblerCreationState creationState) { // todo (6.0) : seems like here is where we ought to determine the SQL selection mappings - final EntityRootInitializer initializer = new EntityRootInitializer( + final EntityResultInitializer initializer = new EntityResultInitializer( this, getNavigablePath(), getLockMode(), diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityRootInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultInitializer.java similarity index 67% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityRootInitializer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultInitializer.java index 30023553bf..f3a7300bb7 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/EntityRootInitializer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultInitializer.java @@ -4,25 +4,26 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; import org.hibernate.LockMode; +import org.hibernate.sql.results.graph.entity.AbstractEntityInitializer; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.EntityResultNode; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.entity.EntityResultGraphNode; +import org.hibernate.sql.results.graph.Initializer; /** * Initializer for cases where the entity is a root domain selection * * @author Steve Ebersole */ -public class EntityRootInitializer extends AbstractEntityInitializer { - public EntityRootInitializer( - EntityResultNode resultDescriptor, +public class EntityResultInitializer extends AbstractEntityInitializer { + public EntityResultInitializer( + EntityResultGraphNode resultDescriptor, NavigablePath navigablePath, LockMode lockMode, DomainResult identifierResult, diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/JoinedSubclassResultImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultJoinedSubclassImpl.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/JoinedSubclassResultImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultJoinedSubclassImpl.java index 4f61a13030..4e0fd94eaf 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/JoinedSubclassResultImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/entity/internal/EntityResultJoinedSubclassImpl.java @@ -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.sql.results.internal.domain.entity; +package org.hibernate.sql.results.graph.entity.internal; import java.util.function.Consumer; @@ -14,15 +14,15 @@ import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.persister.entity.JoinedSubclassEntityPersister; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.tree.from.TableGroup; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.DomainResultCreationState; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * @author Andrea Boriero */ -public class JoinedSubclassResultImpl extends EntityResultImpl { - public JoinedSubclassResultImpl( +public class EntityResultJoinedSubclassImpl extends EntityResultImpl { + public EntityResultJoinedSubclassImpl( NavigablePath navigablePath, EntityValuedModelPart entityValuedModelPart, String resultVariable, @@ -36,7 +36,7 @@ public class JoinedSubclassResultImpl extends EntityResultImpl { AssemblerCreationState creationState) { // todo (6.0) : seems like here is where we ought to determine the SQL selection mappings - final EntityRootInitializer initializer = new EntityRootInitializer( + final EntityResultInitializer initializer = new EntityResultInitializer( this, getNavigablePath(), getLockMode(), diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DynamicInstantiationResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/DynamicInstantiationResult.java similarity index 75% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/DynamicInstantiationResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/DynamicInstantiationResult.java index aa3de946a6..dfcfcbac12 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/DynamicInstantiationResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/DynamicInstantiationResult.java @@ -4,7 +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.sql.results.spi; +package org.hibernate.sql.results.graph.instantiation; + +import org.hibernate.sql.results.graph.DomainResult; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentDomainResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentDomainResult.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentDomainResult.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentDomainResult.java index c8d0297f28..5d42724aac 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentDomainResult.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentDomainResult.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.util.function.Consumer; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentReader.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentReader.java similarity index 80% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentReader.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentReader.java index a2ae7c9f1b..d92bf17205 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/ArgumentReader.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/ArgumentReader.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjection.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjection.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjection.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjection.java index 413ef44d38..31501b436a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjection.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjection.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; -import org.hibernate.sql.results.spi.DomainResultAssembler; +import org.hibernate.sql.results.graph.DomainResultAssembler; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjector.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjector.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjector.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjector.java index 7af4dcebd4..111368197f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjector.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjector.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; /** * Unified contract for injecting a single argument for a dynamic instantiation diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorField.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorField.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorField.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorField.java index e90c59453b..6a81637abc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorField.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorField.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.lang.reflect.Field; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorSetter.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorSetter.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorSetter.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorSetter.java index caa130e083..3f34997e4b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/BeanInjectorSetter.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/BeanInjectorSetter.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiation.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiation.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiation.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiation.java index 88c880cd70..aba8fdd231 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiation.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiation.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.util.ArrayList; import java.util.List; @@ -14,8 +14,8 @@ import java.util.stream.Collectors; import org.hibernate.query.DynamicInstantiationNature; import org.hibernate.query.sqm.sql.ConversionException; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -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; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationArgument.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationArgument.java similarity index 87% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationArgument.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationArgument.java index feb8a29ef6..4528a8c0cc 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationArgument.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationArgument.java @@ -4,10 +4,10 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import org.hibernate.query.sqm.sql.internal.DomainResultProducer; -import org.hibernate.sql.results.spi.DomainResultCreationState; +import org.hibernate.sql.results.graph.DomainResultCreationState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationConstructorAssemblerImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerConstructorImpl.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationConstructorAssemblerImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerConstructorImpl.java index e749c9f66a..b19125b8c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationConstructorAssemblerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerConstructorImpl.java @@ -4,27 +4,27 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.util.List; import org.hibernate.query.sqm.sql.internal.InstantiationException; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class DynamicInstantiationConstructorAssemblerImpl implements DomainResultAssembler { +public class DynamicInstantiationAssemblerConstructorImpl implements DomainResultAssembler { private final Constructor targetConstructor; private final JavaTypeDescriptor resultType; private final List argumentReaders; - public DynamicInstantiationConstructorAssemblerImpl( + public DynamicInstantiationAssemblerConstructorImpl( Constructor targetConstructor, JavaTypeDescriptor resultType, List argumentReaders) { diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationInjectionAssemblerImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationInjectionAssemblerImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java index 66dba3d8ac..2571bca7b0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationInjectionAssemblerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerInjectionImpl.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.beans.PropertyDescriptor; import java.lang.reflect.Field; @@ -14,20 +14,20 @@ import java.util.List; import org.hibernate.internal.util.beans.BeanInfoHelper; import org.hibernate.query.sqm.sql.internal.InstantiationException; import org.hibernate.query.sqm.tree.expression.Compatibility; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** * @author Steve Ebersole */ -public class DynamicInstantiationInjectionAssemblerImpl implements DomainResultAssembler { +public class DynamicInstantiationAssemblerInjectionImpl implements DomainResultAssembler { private final JavaTypeDescriptor target; private final List beanInjections = new ArrayList<>(); @SuppressWarnings("WeakerAccess") - public DynamicInstantiationInjectionAssemblerImpl( + public DynamicInstantiationAssemblerInjectionImpl( JavaTypeDescriptor target, List> argumentReaders) { this.target = target; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationListAssemblerImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerListImpl.java similarity index 77% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationListAssemblerImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerListImpl.java index 12aa9ba6f9..edd8dc23be 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationListAssemblerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerListImpl.java @@ -4,14 +4,14 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.util.ArrayList; import java.util.List; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.jboss.logging.Logger; @@ -24,13 +24,13 @@ import org.jboss.logging.Logger; * * @author Steve Ebersole */ -public class DynamicInstantiationListAssemblerImpl implements DomainResultAssembler { - private static final Logger log = Logger.getLogger( DynamicInstantiationListAssemblerImpl.class ); +public class DynamicInstantiationAssemblerListImpl implements DomainResultAssembler { + private static final Logger log = Logger.getLogger( DynamicInstantiationAssemblerListImpl.class ); private final JavaTypeDescriptor listJavaDescriptor; private final List> argumentReaders; - public DynamicInstantiationListAssemblerImpl( + public DynamicInstantiationAssemblerListImpl( JavaTypeDescriptor listJavaDescriptor, List> argumentReaders) { this.listJavaDescriptor = listJavaDescriptor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationMapAssemblerImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerMapImpl.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationMapAssemblerImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerMapImpl.java index c86e7a576a..e24683b681 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationMapAssemblerImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationAssemblerMapImpl.java @@ -5,7 +5,7 @@ * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.util.HashMap; import java.util.HashSet; @@ -13,9 +13,9 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** @@ -24,11 +24,11 @@ import org.hibernate.type.descriptor.java.JavaTypeDescriptor; * * @author Steve Ebersole */ -public class DynamicInstantiationMapAssemblerImpl implements DomainResultAssembler { +public class DynamicInstantiationAssemblerMapImpl implements DomainResultAssembler { private final JavaTypeDescriptor mapJavaDescriptor; private final List> argumentReaders; - public DynamicInstantiationMapAssemblerImpl( + public DynamicInstantiationAssemblerMapImpl( JavaTypeDescriptor mapJavaDescriptor, List> argumentReaders) { this.mapJavaDescriptor = mapJavaDescriptor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationResultImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationResultImpl.java similarity index 90% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationResultImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationResultImpl.java index 24022cedf3..059023e8ea 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationResultImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/graph/instantiation/internal/DynamicInstantiationResultImpl.java @@ -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.sql.results.internal.domain.instantiation; +package org.hibernate.sql.results.graph.instantiation.internal; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -16,10 +16,10 @@ import java.util.function.Consumer; import org.hibernate.internal.util.StringHelper; import org.hibernate.query.DynamicInstantiationNature; import org.hibernate.query.sqm.tree.expression.Compatibility; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.DynamicInstantiationResult; -import org.hibernate.sql.results.spi.Initializer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.instantiation.DynamicInstantiationResult; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; import org.jboss.logging.Logger; @@ -110,7 +110,7 @@ public class DynamicInstantiationResultImpl implements DynamicInstantiationRe if ( log.isDebugEnabled() && areAnyArgumentsAliased ) { log.debug( "One or more arguments for List dynamic instantiation (`new list(...)`) specified an alias; ignoring" ); } - return (DomainResultAssembler) new DynamicInstantiationListAssemblerImpl( + return (DomainResultAssembler) new DynamicInstantiationAssemblerListImpl( (JavaTypeDescriptor) javaTypeDescriptor, argumentReaders ); @@ -124,7 +124,7 @@ public class DynamicInstantiationResultImpl implements DynamicInstantiationRe "Map dynamic instantiation contained arguments with duplicated aliases [" + StringHelper.join( ",", duplicatedAliases ) + "]" ); } - return (DomainResultAssembler) new DynamicInstantiationMapAssemblerImpl( + return (DomainResultAssembler) new DynamicInstantiationAssemblerMapImpl( (JavaTypeDescriptor) javaTypeDescriptor, argumentReaders ); @@ -161,7 +161,7 @@ public class DynamicInstantiationResultImpl implements DynamicInstantiationRe } constructor.setAccessible( true ); - return new DynamicInstantiationConstructorAssemblerImpl( + return new DynamicInstantiationAssemblerConstructorImpl( constructor, javaTypeDescriptor, argumentReaders @@ -186,7 +186,7 @@ public class DynamicInstantiationResultImpl implements DynamicInstantiationRe ); } - return new DynamicInstantiationInjectionAssemblerImpl( javaTypeDescriptor, argumentReaders ); + return new DynamicInstantiationAssemblerInjectionImpl( javaTypeDescriptor, argumentReaders ); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/EmptySqlSelection.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/EmptySqlSelection.java deleted file mode 100644 index a033cd03d2..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/EmptySqlSelection.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal; - -import org.hibernate.sql.ast.spi.SqlAstWalker; -import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.type.descriptor.EmptyJdbcValueExtractor; -import org.hibernate.type.descriptor.ValueExtractor; - -/** - * @author Steve Ebersole - */ -public class EmptySqlSelection implements SqlSelection { - private final int position; - - public EmptySqlSelection(int position) { - this.position = position; - } - - @Override - public ValueExtractor getJdbcValueExtractor() { - return EmptyJdbcValueExtractor.INSTANCE; - } - - @Override - public int getJdbcResultSetIndex() { - return -1; - } - - @Override - public int getValuesArrayPosition() { - return position; - } - - @Override - public void accept(SqlAstWalker sqlAstWalker) { - throw new UnsupportedOperationException( "Unexpected call to render empty EmptySqlSelection" ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/Helper.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/Helper.java index 50f1011f2b..75dbba1da9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/Helper.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/Helper.java @@ -12,10 +12,10 @@ import java.util.function.Consumer; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.exec.spi.Callback; -import org.hibernate.sql.results.SqlResultsLogger; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.JdbcValues; +import org.hibernate.sql.results.ResultsLogger; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; import org.hibernate.sql.results.spi.RowReader; import org.hibernate.sql.results.spi.RowTransformer; @@ -44,9 +44,9 @@ public class Helper { } private static Consumer getInitializerConsumer(List initializers) { - if ( SqlResultsLogger.INSTANCE.isDebugEnabled() ) { + if ( ResultsLogger.INSTANCE.isDebugEnabled() ) { return initializer -> { - SqlResultsLogger.INSTANCE.debug( "Adding initializer : " + initializer ); + ResultsLogger.INSTANCE.debug( "Adding initializer : " + initializer ); initializers.add( initializer ); }; } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/LoadingCollectionEntryImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/LoadingCollectionEntryImpl.java index 9abd9c8703..862feb9d97 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/LoadingCollectionEntryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/LoadingCollectionEntryImpl.java @@ -15,9 +15,8 @@ import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.sql.exec.spi.ExecutionContext; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; /** * Represents a collection currently being loaded. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/NullValueAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/NullValueAssembler.java index 829da5bc12..f79506f6c1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/NullValueAssembler.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/NullValueAssembler.java @@ -6,9 +6,9 @@ */ package org.hibernate.sql.results.internal; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowProcessingStateStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowProcessingStateStandardImpl.java index fb4d7ed2b4..32d44eef7e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowProcessingStateStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/RowProcessingStateStandardImpl.java @@ -10,15 +10,16 @@ import java.sql.SQLException; import java.util.List; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl; import org.hibernate.loader.plan.spi.EntityFetch; import org.hibernate.query.NavigablePath; import org.hibernate.query.spi.QueryOptions; import org.hibernate.query.spi.QueryParameterBindings; import org.hibernate.sql.exec.spi.Callback; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.JdbcValues; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingState; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.sql.results.spi.RowReader; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/SqlSelectionImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/SqlSelectionImpl.java index d7c9455671..ebafd0a8ad 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/SqlSelectionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/SqlSelectionImpl.java @@ -10,7 +10,7 @@ import java.util.Objects; import org.hibernate.metamodel.mapping.JdbcMapping; import org.hibernate.metamodel.mapping.SqlExpressable; -import org.hibernate.sql.ast.spi.SqlAstWalker; +import org.hibernate.sql.ast.SqlAstWalker; import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.ast.tree.expression.Expression; import org.hibernate.type.descriptor.ValueExtractor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java index 95519165e5..90bf5c0e70 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardRowReader.java @@ -9,16 +9,15 @@ package org.hibernate.sql.results.internal; import java.util.List; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.metamodel.mapping.EntityValuedModelPart; import org.hibernate.query.named.RowReaderMemento; import org.hibernate.sql.exec.spi.Callback; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingState; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.entity.EntityInitializer; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.sql.results.spi.RowReader; import org.hibernate.sql.results.spi.RowTransformer; @@ -78,12 +77,6 @@ public class StandardRowReader implements RowReader { return initializers; } - @Override - public int getNumberOfResults() { - return rowTransformer.determineNumberOfResultElements( assemblerCount ); - } - - @Override public T readRow(RowProcessingState rowProcessingState, JdbcValuesSourceProcessingOptions options) { LOG.debug( "---Processing Row---" ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/TupleImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/TupleImpl.java index 0ab5be6b75..3b56125709 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/TupleImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/TupleImpl.java @@ -4,7 +4,6 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ - package org.hibernate.sql.results.internal; import java.util.List; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/ArrayInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/ArrayInitializer.java deleted file mode 100644 index 6abe64d347..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/ArrayInitializer.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.collection.internal.PersistentArrayHolder; -import org.hibernate.metamodel.mapping.PluralAttributeMapping; -import org.hibernate.persister.collection.CollectionPersister; -import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.RowProcessingState; - -/** - * @author Chris Cranford - */ -public class ArrayInitializer implements CollectionInitializer { - private final CollectionPersister arrayDescriptor; - private final NavigablePath navigablePath; -// private final DomainResultAssembler listIndexAssembler; -// private final DomainResultAssembler elementAssembler; - -// public ArrayInitializer( -// CollectionPersister arrayDescriptor, -// FetchParentAccess parentAccess, -// NavigablePath navigablePath, -// boolean selected, -// LockMode lockMode, -// DomainResultAssembler keyContainerAssembler, -// DomainResultAssembler keyCollectionAssembler, -// DomainResultAssembler listIndexAssembler, -// DomainResultAssembler elementAssembler) { -// super( arrayDescriptor, parentAccess, navigablePath, selected, lockMode, keyContainerAssembler, keyCollectionAssembler ); -// this.listIndexAssembler = listIndexAssembler; -// this.elementAssembler = elementAssembler; -// } - - public ArrayInitializer( - CollectionPersister arrayDescriptor, - NavigablePath navigablePath) { - this.arrayDescriptor = arrayDescriptor; - this.navigablePath = navigablePath; - } - - @Override - public PluralAttributeMapping getInitializedPart() { - throw new NotYetImplementedFor6Exception( getClass() ); - } - - @Override - public CollectionPersister getInitializingCollectionDescriptor() { - return arrayDescriptor; - } - - @Override - public NavigablePath getNavigablePath() { - return navigablePath; - } - - @Override - public void resolveKey(RowProcessingState rowProcessingState) { - - } - - @Override - public void resolveInstance(RowProcessingState rowProcessingState) { - - } - - @Override - public void initializeInstance(RowProcessingState rowProcessingState) { - - } - - @Override - public void finishUpRow(RowProcessingState rowProcessingState) { - - } - - @Override - public PersistentArrayHolder getCollectionInstance() { - throw new NotYetImplementedFor6Exception( getClass() ); - //return (PersistentArrayHolder) super.getCollectionInstance(); - } - -// @Override -// protected void readCollectionRow(RowProcessingState rowProcessingState) { -// int index = (int) listIndexAssembler.assemble( rowProcessingState ); -// if ( getCollectionDescriptor().getIndexDescriptor().getBaseIndex() != 0 ) { -// index -= getCollectionDescriptor().getIndexDescriptor().getBaseIndex(); -// } -// getCollectionInstance().load( index, elementAssembler.assemble( rowProcessingState ) ); -// } -// -// @Override -// public String toString() { -// return "ArrayInitializer{" + LoggingHelper.toLoggableString( getNavigablePath() ) + ")"; -// } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/BiDirectionalFetchImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/BiDirectionalFetchImpl.java index dbe938f984..8132e940e1 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/BiDirectionalFetchImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/BiDirectionalFetchImpl.java @@ -13,17 +13,17 @@ import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.FetchStrategy; import org.hibernate.engine.FetchTiming; import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.BiDirectionalFetch; -import org.hibernate.sql.results.spi.DomainResultAssembler; -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.FetchParentAccess; -import org.hibernate.sql.results.spi.Fetchable; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.BiDirectionalFetch; +import org.hibernate.sql.results.graph.DomainResultAssembler; +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.FetchParentAccess; +import org.hibernate.sql.results.graph.Fetchable; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; /** @@ -66,6 +66,11 @@ public class BiDirectionalFetchImpl implements BiDirectionalFetch, Fetchable { return fetchable; } + @Override + public JavaTypeDescriptor getResultJavaTypeDescriptor() { + return fetchable.getJavaTypeDescriptor(); + } + @Override public boolean isNullable() { throw new NotYetImplementedFor6Exception( getClass() ); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionDomainResult.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionDomainResult.java deleted file mode 100644 index ccfcbd40e7..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/collection/CollectionDomainResult.java +++ /dev/null @@ -1,315 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.collection; - -import java.util.List; -import java.util.function.Consumer; - -import org.hibernate.LockMode; -import org.hibernate.collection.spi.CollectionInitializerProducer; -import org.hibernate.collection.spi.CollectionSemantics; -import org.hibernate.collection.spi.PersistentCollection; -import org.hibernate.engine.spi.CollectionKey; -import org.hibernate.engine.spi.PersistenceContext; -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.LoadingCollectionEntryImpl; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.CollectionResultNode; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -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.FetchableContainer; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.LoadContexts; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; -import org.hibernate.sql.results.spi.RowProcessingState; -import org.hibernate.type.descriptor.java.JavaTypeDescriptor; - -/** - * @author Steve Ebersole - */ -public class CollectionDomainResult implements DomainResult, CollectionResultNode, FetchParent { - private final NavigablePath loadingPath; - private final PluralAttributeMapping loadingAttribute; - - private final String resultVariable; - - private final DomainResult fkResult; - - private final CollectionInitializerProducer initializerProducer; - - public CollectionDomainResult( - NavigablePath loadingPath, - PluralAttributeMapping loadingAttribute, - String resultVariable, - TableGroup tableGroup, - DomainResultCreationState creationState) { - this.loadingPath = loadingPath; - this.loadingAttribute = loadingAttribute; - this.resultVariable = resultVariable; - - fkResult = loadingAttribute.getKeyDescriptor().createDomainResult( - loadingPath, - tableGroup, - creationState - ); - - final CollectionSemantics collectionSemantics = loadingAttribute.getCollectionDescriptor().getCollectionSemantics(); - initializerProducer = collectionSemantics.createInitializerProducer( - loadingPath, - loadingAttribute, - this, - true, - null, - LockMode.READ, - creationState - ); - } - - @Override - public String getResultVariable() { - return resultVariable; - } - - @Override - public JavaTypeDescriptor getResultJavaTypeDescriptor() { - return loadingAttribute.getJavaTypeDescriptor(); - } - - @Override - public DomainResultAssembler createResultAssembler( - Consumer initializerCollector, - AssemblerCreationState creationState) { - - final DomainResultAssembler fkAssembler = fkResult.createResultAssembler( - initializerCollector, - creationState - ); - - final CollectionInitializer initializer = initializerProducer.produceInitializer( - loadingPath, - loadingAttribute, - null, - LockMode.READ, - fkAssembler, - fkAssembler, - initializerCollector, - creationState - ); - - initializerCollector.accept( initializer ); - - return new EagerCollectionAssembler( loadingAttribute, initializer ); - } - - @Override - public FetchableContainer getReferencedMappingContainer() { - return loadingAttribute; - } - - @Override - public FetchableContainer getReferencedMappingType() { - return getReferencedMappingContainer(); - } - - @Override - public NavigablePath getNavigablePath() { - return loadingPath; - } - - @Override - public List getFetches() { - return null; - } - - @Override - public Fetch findFetch(String fetchableName) { - return null; - } - - - private static class InitializerImpl implements CollectionInitializer { - private final NavigablePath loadingPath; - private final PluralAttributeMapping loadingCollection; - - private final DomainResultAssembler fkAssembler; - private final DomainResultAssembler elementAssembler; - private final DomainResultAssembler indexAssembler; - private final DomainResultAssembler identifierAssembler; - - private CollectionKey collectionKey; - - private boolean managing; - private Object fkValue; - - // todo (6.0) : consider using the initializer itself as the holder of the various "temp" collections - // used while reading a collection. that would mean collection-type specific initializers (List, versus Set) - private PersistentCollection instance; - - public InitializerImpl( - NavigablePath loadingPath, - PluralAttributeMapping loadingCollection, - DomainResult fkResult, - Fetch elementFetch, - Fetch indexFetch, - DomainResult identifierResult, - Consumer collector, - AssemblerCreationState creationState) { - this.loadingPath = loadingPath; - this.loadingCollection = loadingCollection; - - this.fkAssembler = fkResult.createResultAssembler( collector, creationState ); - - // questionable what should be the parent access here - this.elementAssembler = elementFetch.createAssembler( null, collector, creationState ); - this.indexAssembler = indexFetch == null - ? null - : indexFetch.createAssembler( null, collector, creationState ); - this.identifierAssembler = identifierResult == null - ? null - : identifierResult.createResultAssembler( collector, creationState ); - } - - @Override - public PluralAttributeMapping getInitializedPart() { - return loadingCollection; - } - - @Override - public PersistentCollection getCollectionInstance() { - return instance; - } - - @Override - public NavigablePath getNavigablePath() { - return loadingPath; - } - - @Override - public void finishUpRow(RowProcessingState rowProcessingState) { - collectionKey = null; - managing = false; - instance = null; - } - - @Override - public void resolveKey(RowProcessingState rowProcessingState) { - if ( collectionKey != null ) { - // already resolved - return; - } - - final Object fkValue = fkAssembler.assemble( rowProcessingState ); - assert fkValue != null; - - collectionKey = new CollectionKey( - loadingCollection.getCollectionDescriptor(), - fkValue - ); - } - - @Override - public void resolveInstance(RowProcessingState rowProcessingState) { - if ( instance != null ) { - // already resolved - return; - } - - final PersistenceContext persistenceContext = rowProcessingState.getSession().getPersistenceContext(); - - // see if the collection is already being initialized - - final LoadContexts loadContexts = persistenceContext.getLoadContexts(); - final LoadingCollectionEntry existingEntry = loadContexts.findLoadingCollectionEntry( collectionKey ); - - if ( existingEntry != null ) { - this.instance = existingEntry.getCollectionInstance(); - if ( existingEntry.getInitializer() == this ) { - this.managing = true; - } - return; - } - - // see if it has been already registered with the Session - - final PersistentCollection registeredInstance = persistenceContext.getCollection( collectionKey ); - if ( registeredInstance != null ) { - this.instance = registeredInstance; - // it was already registered, so use that wrapper. - if ( ! registeredInstance.wasInitialized() ) { - // if the existing wrapper is not initialized, we will take responsibility for initializing it - managing = true; - rowProcessingState.getJdbcValuesSourceProcessingState().registerLoadingCollection( - collectionKey, - new LoadingCollectionEntryImpl( - getInitializingCollectionDescriptor(), - this, - collectionKey, - registeredInstance - ) - ); - return; - } - } - - this.instance = makePersistentCollection( loadingCollection, collectionKey, rowProcessingState ); - this.managing = true; - - rowProcessingState.getJdbcValuesSourceProcessingState().registerLoadingCollection( - collectionKey, - new LoadingCollectionEntryImpl( - loadingCollection.getCollectionDescriptor(), - this, - collectionKey.getKey(), - instance - ) - ); - - } - - private static PersistentCollection makePersistentCollection( - PluralAttributeMapping fetchedMapping, - CollectionKey collectionKey, - RowProcessingState rowProcessingState) { - final CollectionPersister collectionDescriptor = fetchedMapping.getCollectionDescriptor(); - final CollectionSemantics collectionSemantics = collectionDescriptor.getCollectionSemantics(); - return collectionSemantics.instantiateWrapper( - collectionKey.getKey(), - collectionDescriptor, - rowProcessingState.getSession() - ); - } - - @Override - public void initializeInstance(RowProcessingState rowProcessingState) { - if ( ! managing ) { - return; - } - - final Object fkValue = fkAssembler.assemble( rowProcessingState ); - if ( fkValue == null ) { - // this row contains no collection element - return; - } - - final PersistentCollection collectionInstance = getCollectionInstance(); - collectionInstance.readFrom( - rowProcessingState, - elementAssembler, - indexAssembler, - identifierAssembler, - collectionInstance.getOwner() - ); - } - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetchInitializer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetchInitializer.java deleted file mode 100644 index ce5f2842f1..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/composite/CompositeFetchInitializer.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.composite; - -import java.util.function.Consumer; - -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.CompositeInitializer; -import org.hibernate.sql.results.spi.CompositeResultNode; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Initializer; - -/** - * @author Steve Ebersole - */ -public class CompositeFetchInitializer - extends AbstractCompositeInitializer - implements CompositeInitializer { - public CompositeFetchInitializer( - FetchParentAccess fetchParentAccess, - CompositeResultNode resultDescriptor, - Consumer initializerConsumer, - AssemblerCreationState creationState) { - super( resultDescriptor, fetchParentAccess, initializerConsumer, creationState ); - } - - @Override - public Object getParentKey() { - return getFetchParentAccess().getParentKey(); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityFetch.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityFetch.java deleted file mode 100644 index 553793313a..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/AbstractEntityFetch.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.entity; - -import java.util.function.Consumer; - -import org.hibernate.LockMode; -import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.Fetch; -import org.hibernate.sql.results.spi.FetchParent; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Fetchable; -import org.hibernate.sql.results.spi.Initializer; - -/** - * @author Andrea Boriero - */ -public abstract class AbstractEntityFetch implements Fetch { - private final FetchParent fetchParent; - private final Fetchable fetchedAttribute; - private final NavigablePath navigablePath; - private final boolean nullable; - private final LockMode lockMode; - - public AbstractEntityFetch( - FetchParent fetchParent, - Fetchable fetchedAttribute, - NavigablePath navigablePath, - boolean nullable, - LockMode lockMode) { - this.fetchParent = fetchParent; - this.fetchedAttribute = fetchedAttribute; - this.navigablePath = navigablePath; - this.nullable = nullable; - this.lockMode = lockMode; - } - - @Override - public FetchParent getFetchParent() { - return fetchParent; - } - - @Override - public Fetchable getFetchedMapping() { - return fetchedAttribute; - } - - @Override - public NavigablePath getNavigablePath() { - return navigablePath; - } - - @Override - public boolean isNullable() { - return nullable; - } - - @Override - public DomainResultAssembler createAssembler( - FetchParentAccess parentAccess, Consumer collector, AssemblerCreationState creationState) { - EntityInitializer entityInitializer = getEntityInitializer( - parentAccess, - collector, - creationState - ); - collector.accept( entityInitializer ); - return new EntityAssembler( getFetchedMapping().getJavaTypeDescriptor(), entityInitializer ); - } - - public LockMode getLockMode() { - return lockMode; - } - - protected abstract EntityInitializer getEntityInitializer( - FetchParentAccess parentAccess, - Consumer collector, - AssemblerCreationState creationState); -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchImpl.java deleted file mode 100644 index 234395ca97..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/DelayedEntityFetchImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.entity; - -import java.util.function.Consumer; - -import org.hibernate.LockMode; -import org.hibernate.metamodel.mapping.internal.SingularAssociationAttributeMapping; -import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultCreationState; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.FetchParent; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Initializer; - -/** - * @author Andrea Boriero - * @author Steve Ebersole - */ -public class DelayedEntityFetchImpl extends AbstractEntityFetch { - - private final DomainResult result; - - public DelayedEntityFetchImpl( - FetchParent fetchParent, - SingularAssociationAttributeMapping fetchedAttribute, - LockMode lockMode, - boolean nullable, - NavigablePath navigablePath, - DomainResult result) { - super( fetchParent, fetchedAttribute, navigablePath, nullable, lockMode ); - this.result = result; - } - - @Override - protected EntityInitializer getEntityInitializer( - FetchParentAccess parentAccess, - Consumer collector, - AssemblerCreationState creationState) { - final SingularAssociationAttributeMapping fetchedAttribute = (SingularAssociationAttributeMapping) getFetchedMapping(); - return new DelayedEntityFetchInitializer( - getNavigablePath(), - (EntityPersister) fetchedAttribute.getMappedTypeDescriptor(), - result.createResultAssembler( collector, creationState ) - ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityFetchImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityFetchImpl.java deleted file mode 100644 index c31f309f4b..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/entity/SelectEntityFetchImpl.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.entity; - -import java.util.function.Consumer; - -import org.hibernate.LockMode; -import org.hibernate.metamodel.mapping.internal.SingularAssociationAttributeMapping; -import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.query.NavigablePath; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.EntityInitializer; -import org.hibernate.sql.results.spi.FetchParent; -import org.hibernate.sql.results.spi.FetchParentAccess; -import org.hibernate.sql.results.spi.Initializer; - -/** - * @author Andrea Boriero - */ -public class SelectEntityFetchImpl extends AbstractEntityFetch { - - private final DomainResult result; - - public SelectEntityFetchImpl( - FetchParent fetchParent, - SingularAssociationAttributeMapping fetchedAttribute, - LockMode lockMode, - NavigablePath navigablePath, - DomainResult result) { - super( fetchParent, fetchedAttribute, navigablePath, fetchedAttribute.isNullable(), lockMode ); - this.result = result; - } - - - @Override - protected EntityInitializer getEntityInitializer( - FetchParentAccess parentAccess, - Consumer collector, - AssemblerCreationState creationState) { - final SingularAssociationAttributeMapping fetchedAttribute = (SingularAssociationAttributeMapping) getFetchedMapping(); - - return new SelectEntityInitializer( - getNavigablePath(), - (EntityPersister) fetchedAttribute.getMappedTypeDescriptor(), - result.createResultAssembler( collector, creationState ), - fetchedAttribute.isUnwrapProxy(), - fetchedAttribute.isNullable() - ); - } - - -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationAssembler.java b/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationAssembler.java deleted file mode 100644 index 1ff6742dd3..0000000000 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/domain/instantiation/DynamicInstantiationAssembler.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later - * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html - */ -package org.hibernate.sql.results.internal.domain.instantiation; - -import java.util.List; - -import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.RowProcessingState; -import org.hibernate.type.descriptor.java.JavaTypeDescriptor; - -/** - * @author Steve Ebersole - */ -public class DynamicInstantiationAssembler implements DomainResultAssembler { - private final JavaTypeDescriptor javaTypeDescriptor; - - public DynamicInstantiationAssembler(JavaTypeDescriptor javaTypeDescriptor, List sqlSelections) { - this.javaTypeDescriptor = javaTypeDescriptor; - } - - @Override - public JavaTypeDescriptor getAssembledJavaTypeDescriptor() { - return javaTypeDescriptor; - } - - @Override - public Object assemble(RowProcessingState rowProcessingState, JdbcValuesSourceProcessingOptions options) { - throw new NotYetImplementedFor6Exception( ); - } -} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractJdbcValues.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractJdbcValues.java similarity index 83% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractJdbcValues.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractJdbcValues.java index f0fc8fc958..00fc7c8c02 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractJdbcValues.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractJdbcValues.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.SQLException; -import org.hibernate.sql.results.internal.caching.QueryCachePutManager; -import org.hibernate.sql.results.spi.JdbcValues; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.caching.QueryCachePutManager; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractResultSetAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractResultSetAccess.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractResultSetAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractResultSetAccess.java index c513308e32..1ee5275bd5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/AbstractResultSetAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/AbstractResultSetAccess.java @@ -4,13 +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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.ResultSetMetaData; import java.sql.SQLException; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/DeferredResultSetAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DeferredResultSetAccess.java similarity index 98% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/DeferredResultSetAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DeferredResultSetAccess.java index f925e192cd..e5f25129ff 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/DeferredResultSetAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DeferredResultSetAccess.java @@ -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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/DirectResultSetAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DirectResultSetAccess.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/DirectResultSetAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DirectResultSetAccess.java index 0d904db4d6..34ca7c82cd 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/DirectResultSetAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/DirectResultSetAccess.java @@ -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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.PreparedStatement; import java.sql.ResultSet; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesCacheHit.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java similarity index 88% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesCacheHit.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java index f1f2d7607d..c2cafa085e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesCacheHit.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesCacheHit.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.util.List; -import org.hibernate.sql.results.internal.caching.QueryCachePutManagerDisabledImpl; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.caching.internal.QueryCachePutManagerDisabledImpl; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * A JdbcValuesSource implementation for cases where we had a cache hit. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerDefined.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerDefined.java similarity index 84% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerDefined.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerDefined.java index 45694a2e7c..824fde98d5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerDefined.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerDefined.java @@ -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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.util.List; import java.util.Set; @@ -12,10 +12,10 @@ import java.util.Set; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** * ResultSetMapping for handling selections for a {@link org.hibernate.query.NativeQuery} diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerLegacy.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerLegacy.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerLegacy.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerLegacy.java index 1655ce95ab..be5488726a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerLegacy.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerLegacy.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.spi.TypeConfiguration; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerStandard.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerStandard.java similarity index 82% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerStandard.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerStandard.java index a2f768bbb7..5fe4163565 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerStandard.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerStandard.java @@ -4,17 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.util.List; -import java.util.Set; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; /** * Hibernate's standard ResultSetMappingDescriptor implementation for cases diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerUndefined.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerUndefined.java similarity index 93% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerUndefined.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerUndefined.java index 9d3d5410b2..9d9cdec06e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesMappingProducerUndefined.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesMappingProducerUndefined.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.JdbcValuesMappingProducer; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMappingProducer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesResultSetImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesResultSetImpl.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesResultSetImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesResultSetImpl.java index fd7ef01d41..c158b0b727 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesResultSetImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesResultSetImpl.java @@ -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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.SQLException; @@ -17,11 +17,11 @@ import org.hibernate.sql.ast.spi.SqlSelection; import org.hibernate.sql.exec.ExecutionException; import org.hibernate.sql.exec.internal.JdbcExecHelper; import org.hibernate.sql.exec.spi.ExecutionContext; -import org.hibernate.sql.results.internal.caching.QueryCachePutManager; -import org.hibernate.sql.results.internal.caching.QueryCachePutManagerDisabledImpl; -import org.hibernate.sql.results.internal.caching.QueryCachePutManagerEnabledImpl; -import org.hibernate.sql.results.spi.JdbcValuesMapping; -import org.hibernate.sql.results.spi.RowProcessingState; +import org.hibernate.sql.results.caching.QueryCachePutManager; +import org.hibernate.sql.results.caching.internal.QueryCachePutManagerDisabledImpl; +import org.hibernate.sql.results.caching.internal.QueryCachePutManagerEnabledImpl; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; /** * JdbcValuesSource implementation for a JDBC ResultSet as the source diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesSourceProcessingStateStandardImpl.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java similarity index 91% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesSourceProcessingStateStandardImpl.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java index 5eea406ec3..620331e08b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/JdbcValuesSourceProcessingStateStandardImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/JdbcValuesSourceProcessingStateStandardImpl.java @@ -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.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.util.ArrayList; import java.util.HashMap; @@ -18,14 +18,14 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.spi.EventSource; import org.hibernate.event.spi.PostLoadEvent; import org.hibernate.event.spi.PreLoadEvent; +import org.hibernate.sql.results.graph.collection.internal.ArrayInitializer; import org.hibernate.query.spi.QueryOptions; import org.hibernate.sql.exec.spi.ExecutionContext; -import org.hibernate.sql.results.internal.domain.ArrayInitializer; -import org.hibernate.sql.results.spi.CollectionInitializer; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingOptions; -import org.hibernate.sql.results.spi.JdbcValuesSourceProcessingState; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; -import org.hibernate.sql.results.spi.LoadingEntityEntry; +import org.hibernate.sql.results.graph.collection.CollectionInitializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; +import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/ResultSetAccess.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/ResultSetAccess.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/ResultSetAccess.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/ResultSetAccess.java index f0598e215e..8533f7023d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/ResultSetAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/ResultSetAccess.java @@ -4,13 +4,13 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.sql.ResultSet; import java.sql.SQLException; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.results.spi.JdbcValuesMetadata; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMetadata; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardJdbcValuesMapping.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/StandardJdbcValuesMapping.java similarity index 81% rename from hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardJdbcValuesMapping.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/StandardJdbcValuesMapping.java index 8c587cf51e..b4573cdbd5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/internal/StandardJdbcValuesMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/internal/StandardJdbcValuesMapping.java @@ -4,19 +4,18 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.internal; +package org.hibernate.sql.results.jdbc.internal; import java.util.List; -import java.util.Set; import java.util.function.Consumer; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.sql.ast.spi.SqlSelection; -import org.hibernate.sql.results.spi.AssemblerCreationState; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; -import org.hibernate.sql.results.spi.Initializer; -import org.hibernate.sql.results.spi.JdbcValuesMapping; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValues.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValues.java similarity index 97% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValues.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValues.java index 107e0b1928..f713c0d7c5 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValues.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValues.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import java.sql.SQLException; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMapping.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMapping.java similarity index 78% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMapping.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMapping.java index d9d56af841..151d7ad9b4 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMapping.java @@ -4,11 +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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import java.util.List; import java.util.function.Consumer; +import org.hibernate.sql.results.graph.AssemblerCreationState; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.sql.ast.spi.SqlSelection; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMappingProducer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMappingProducer.java similarity index 96% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMappingProducer.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMappingProducer.java index 309511b4be..2b80b036b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMappingProducer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMappingProducer.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.query.spi.ResultSetMapping; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMetadata.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMetadata.java similarity index 95% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMetadata.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMetadata.java index 1f96aeb9d1..ecb6e12e07 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesMetadata.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesMetadata.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingOptions.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingOptions.java similarity index 92% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingOptions.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingOptions.java index 584bd30612..97abcebf3b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingOptions.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingOptions.java @@ -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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import java.io.Serializable; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingState.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingState.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingState.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingState.java index 99868fd269..9d8a93ac8e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/JdbcValuesSourceProcessingState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/JdbcValuesSourceProcessingState.java @@ -4,13 +4,16 @@ * License: GNU Lesser General Public License (LGPL), version 2.1 or later * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html */ -package org.hibernate.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; import org.hibernate.engine.spi.CollectionKey; import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.event.spi.PostLoadEvent; import org.hibernate.event.spi.PreLoadEvent; +import org.hibernate.sql.results.spi.LoadContexts; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; +import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; import org.hibernate.query.spi.QueryOptions; import org.hibernate.sql.exec.spi.ExecutionContext; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowProcessingState.java b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/RowProcessingState.java similarity index 94% rename from hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowProcessingState.java rename to hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/RowProcessingState.java index 13d571907c..1a8ccbef1e 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowProcessingState.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/jdbc/spi/RowProcessingState.java @@ -4,8 +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.sql.results.spi; +package org.hibernate.sql.results.jdbc.spi; +import org.hibernate.sql.results.graph.Initializer; import org.hibernate.loader.plan.spi.EntityFetch; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.spi.SqlSelection; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/package-info.java b/hibernate-core/src/main/java/org/hibernate/sql/results/package-info.java index 638d0c2b34..8a50b8727d 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/package-info.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/package-info.java @@ -6,6 +6,8 @@ */ /** - * Package for processing JDBC ResultSets into domain results + * Package for processing JDBC ResultSets into hydrated domain model graphs based on a "load plan" + * defined by a "domain result graph" - one or more {@link org.hibernate.sql.results.graph.DomainResult} nodes + * with zero-or-more {@link org.hibernate.sql.results.graph.Fetch} nodes */ package org.hibernate.sql.results; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CircularFetchDetector.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CircularFetchDetector.java index 856e899fed..6831a5a57a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CircularFetchDetector.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/CircularFetchDetector.java @@ -7,6 +7,9 @@ package org.hibernate.sql.results.spi; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.FetchParent; +import org.hibernate.sql.results.graph.Fetchable; import org.hibernate.query.NavigablePath; import org.hibernate.sql.ast.spi.SqlAstProcessingState; import org.hibernate.sql.results.internal.domain.BiDirectionalFetchImpl; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ListResultsConsumer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ListResultsConsumer.java index 0d107e0459..3f84949f45 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ListResultsConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ListResultsConsumer.java @@ -11,8 +11,10 @@ import java.util.ArrayList; import java.util.List; import org.hibernate.engine.spi.SharedSessionContractImplementor; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; import org.hibernate.persister.entity.EntityPersister; -import org.hibernate.sql.results.internal.JdbcValuesSourceProcessingStateStandardImpl; +import org.hibernate.sql.results.jdbc.internal.JdbcValuesSourceProcessingStateStandardImpl; import org.hibernate.sql.results.internal.RowProcessingStateStandardImpl; /** diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadContexts.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadContexts.java index 529d519ec3..0436459e4b 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadContexts.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/LoadContexts.java @@ -13,6 +13,9 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.collections.StandardStack; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; +import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; /** * Maintains a Stack of processing state related to performing load operations. diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultsConsumer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultsConsumer.java index 8f9a615f07..02b65879fb 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultsConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ResultsConsumer.java @@ -7,8 +7,10 @@ package org.hibernate.sql.results.spi; 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.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; /** * @author Steve Ebersole diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowReader.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowReader.java index 1a04bc2753..35a640e2e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowReader.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/RowReader.java @@ -10,6 +10,10 @@ import java.sql.SQLException; import java.util.List; import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.sql.results.graph.Initializer; +import org.hibernate.sql.results.jdbc.spi.RowProcessingState; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState; import org.hibernate.query.named.RowReaderMemento; /** @@ -25,17 +29,10 @@ public interface RowReader { */ Class getResultJavaType(); - List getInitializers(); - /** - * How many results (domain selections) are returned by this reader? - * - * @apiNote If this method returns `> 1` then {@link #getResultJavaType()} - * should return either `Object[].class` (or {@link javax.persistence.Tuple}?). - * - * todo (6.0) : determine this ^^ + * The initializers associated with this reader */ - int getNumberOfResults(); + List getInitializers(); /** * The actual coordination of reading a row diff --git a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java index 393d20e3d5..71c497d6cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/results/spi/ScrollableResultsConsumer.java @@ -9,8 +9,11 @@ package org.hibernate.sql.results.spi; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.internal.FetchingScrollableResultsImpl; import org.hibernate.internal.ScrollableResultsImpl; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesMapping; +import org.hibernate.sql.results.jdbc.spi.JdbcValues; +import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions; 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; /** diff --git a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java index 9ba297848e..db36a8b28e 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CollectionType.java @@ -45,7 +45,7 @@ import org.hibernate.persister.entity.Joinable; import org.hibernate.pretty.MessageHelper; import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.LazyInitializer; -import org.hibernate.sql.results.spi.LoadingCollectionEntry; +import org.hibernate.sql.results.graph.collection.LoadingCollectionEntry; import org.hibernate.type.spi.TypeConfiguration; import org.jboss.logging.Logger; diff --git a/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/EntityGraphLoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/EntityGraphLoadPlanBuilderTest.java deleted file mode 100644 index 4f0deec1fb..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/jpa/test/graphs/EntityGraphLoadPlanBuilderTest.java +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.jpa.test.graphs; - -import java.util.Iterator; -import java.util.Set; -import javax.persistence.ElementCollection; -import javax.persistence.Embeddable; -import javax.persistence.Embedded; -import javax.persistence.Entity; -import javax.persistence.EntityGraph; -import javax.persistence.EntityManager; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; - - -import org.junit.Test; - -import static org.junit.Assert.*; - -import org.hibernate.LockMode; -import org.hibernate.engine.spi.EffectiveEntityGraph; -import org.hibernate.engine.spi.LoadQueryInfluencers; -import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.graph.GraphSemantic; -import org.hibernate.graph.spi.RootGraphImplementor; -import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase; -import org.hibernate.loader.plan.build.internal.FetchGraphLoadPlanBuildingStrategy; -import org.hibernate.loader.plan.build.internal.LoadGraphLoadPlanBuildingStrategy; -import org.hibernate.loader.plan.build.internal.AbstractLoadPlanBuildingAssociationVisitationStrategy; -import org.hibernate.loader.plan.build.spi.LoadPlanTreePrinter; -import org.hibernate.loader.plan.build.spi.MetamodelDrivenLoadPlanBuilder; -import org.hibernate.loader.plan.exec.internal.AliasResolutionContextImpl; -import org.hibernate.loader.plan.spi.Join; -import org.hibernate.loader.plan.spi.LoadPlan; -import org.hibernate.loader.plan.spi.QuerySpace; -import org.hibernate.persister.entity.EntityPersister; - -/** - * @author Strong Liu - */ -public class EntityGraphLoadPlanBuilderTest extends BaseEntityManagerFunctionalTestCase { - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { Cat.class, Person.class, Country.class, Dog.class, ExpressCompany.class }; - } - - @Entity - public static class Dog { - @Id - String name; - @ElementCollection - Set favorites; - } - - @Entity - public static class Cat { - @Id - String name; - @ManyToOne(fetch = FetchType.LAZY) - Person owner; - - } - - @Entity - public static class Person { - @Id - String name; - @OneToMany(mappedBy = "owner") - Set pets; - @Embedded - Address homeAddress; - } - - @Embeddable - public static class Address { - @ManyToOne - Country country; - } - - @Entity - public static class ExpressCompany { - @Id - String name; - @ElementCollection - Set
shipAddresses; - } - - @Entity - public static class Country { - @Id - String name; - } - - /** - * EntityGraph(1): - * - * Cat - * - * LoadPlan: - * - * Cat - * - * --------------------- - * - * EntityGraph(2): - * - * Cat - * owner -- Person - * - * LoadPlan: - * - * Cat - * owner -- Person - * address --- Address - */ - @Test - public void testBasicFetchLoadPlanBuilding() { - EntityManager em = getOrCreateEntityManager(); - EntityGraph eg = em.createEntityGraph( Cat.class ); - LoadPlan plan = buildLoadPlan( eg, GraphSemantic.FETCH, Cat.class ); - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sfi() ) ); - QuerySpace rootQuerySpace = plan.getQuerySpaces().getRootQuerySpaces().get( 0 ); - assertFalse( - "With fetchgraph property and an empty EntityGraph, there should be no join at all", - rootQuerySpace.getJoins().iterator().hasNext() - ); - // -------------------------------------------------- another a little more complicated case - eg = em.createEntityGraph( Cat.class ); - eg.addSubgraph( "owner", Person.class ); - plan = buildLoadPlan( eg, GraphSemantic.FETCH, Cat.class ); - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sfi() ) ); - rootQuerySpace = plan.getQuerySpaces().getRootQuerySpaces().get( 0 ); - Iterator iterator = rootQuerySpace.getJoins().iterator(); - assertTrue( - "With fetchgraph property and an empty EntityGraph, there should be no join at all", iterator.hasNext() - ); - Join personJoin = iterator.next(); - assertNotNull( personJoin ); - QuerySpace.Disposition disposition = personJoin.getRightHandSide().getDisposition(); - assertEquals( - "This should be an entity join which fetches Person", QuerySpace.Disposition.ENTITY, disposition - ); - - iterator = personJoin.getRightHandSide().getJoins().iterator(); - assertTrue( "The composite address should be fetched", iterator.hasNext() ); - Join addressJoin = iterator.next(); - assertNotNull( addressJoin ); - disposition = addressJoin.getRightHandSide().getDisposition(); - assertEquals( QuerySpace.Disposition.COMPOSITE, disposition ); - assertFalse( iterator.hasNext() ); - assertFalse( - "The ManyToOne attribute in composite should not be fetched", - addressJoin.getRightHandSide().getJoins().iterator().hasNext() - ); - em.close(); - } - - /** - * EntityGraph(1): - * - * Cat - * - * LoadPlan: - * - * Cat - * - * --------------------- - * - * EntityGraph(2): - * - * Cat - * owner -- Person - * - * LoadPlan: - * - * Cat - * owner -- Person - * address --- Address - * country -- Country - */ - @Test - public void testBasicLoadLoadPlanBuilding() { - EntityManager em = getOrCreateEntityManager(); - EntityGraph eg = em.createEntityGraph( Cat.class ); - LoadPlan plan = buildLoadPlan( eg, GraphSemantic.LOAD, Cat.class ); - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sfi() ) ); - QuerySpace rootQuerySpace = plan.getQuerySpaces().getRootQuerySpaces().get( 0 ); - assertFalse( - "With fetchgraph property and an empty EntityGraph, there should be no join at all", - rootQuerySpace.getJoins().iterator().hasNext() - ); - // -------------------------------------------------- another a little more complicated case - eg = em.createEntityGraph( Cat.class ); - eg.addSubgraph( "owner", Person.class ); - plan = buildLoadPlan( eg, GraphSemantic.LOAD, Cat.class ); - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sfi() ) ); - rootQuerySpace = plan.getQuerySpaces().getRootQuerySpaces().get( 0 ); - Iterator iterator = rootQuerySpace.getJoins().iterator(); - assertTrue( - "With fetchgraph property and an empty EntityGraph, there should be no join at all", iterator.hasNext() - ); - Join personJoin = iterator.next(); - assertNotNull( personJoin ); - QuerySpace.Disposition disposition = personJoin.getRightHandSide().getDisposition(); - assertEquals( - "This should be an entity join which fetches Person", QuerySpace.Disposition.ENTITY, disposition - ); - - iterator = personJoin.getRightHandSide().getJoins().iterator(); - assertTrue( "The composite address should be fetched", iterator.hasNext() ); - Join addressJoin = iterator.next(); - assertNotNull( addressJoin ); - disposition = addressJoin.getRightHandSide().getDisposition(); - assertEquals( QuerySpace.Disposition.COMPOSITE, disposition ); - iterator = addressJoin.getRightHandSide().getJoins().iterator(); - assertTrue( iterator.hasNext() ); - Join countryJoin = iterator.next(); - assertNotNull( countryJoin ); - disposition = countryJoin.getRightHandSide().getDisposition(); - assertEquals( QuerySpace.Disposition.ENTITY, disposition ); - assertFalse( - "The ManyToOne attribute in composite should not be fetched", - countryJoin.getRightHandSide().getJoins().iterator().hasNext() - ); - em.close(); - } - - - @Test - public void testBasicElementCollections() { - EntityManager em = getOrCreateEntityManager(); - EntityGraph eg = em.createEntityGraph( Dog.class ); - eg.addAttributeNodes( "favorites" ); - LoadPlan loadLoadPlan = buildLoadPlan( eg, GraphSemantic.LOAD, Dog.class ); //WTF name!!! - LoadPlanTreePrinter.INSTANCE.logTree( loadLoadPlan, new AliasResolutionContextImpl( sfi() ) ); - QuerySpace querySpace = loadLoadPlan.getQuerySpaces().getRootQuerySpaces().iterator().next(); - Iterator iterator = querySpace.getJoins().iterator(); - assertTrue( iterator.hasNext() ); - Join collectionJoin = iterator.next(); - assertEquals( QuerySpace.Disposition.COLLECTION, collectionJoin.getRightHandSide().getDisposition() ); - assertFalse( iterator.hasNext() ); - //---------------------------------------------------------------- - LoadPlan fetchLoadPlan = buildLoadPlan( eg, GraphSemantic.FETCH, Dog.class ); - LoadPlanTreePrinter.INSTANCE.logTree( fetchLoadPlan, new AliasResolutionContextImpl( sfi() ) ); - querySpace = fetchLoadPlan.getQuerySpaces().getRootQuerySpaces().iterator().next(); - iterator = querySpace.getJoins().iterator(); - assertTrue( iterator.hasNext() ); - collectionJoin = iterator.next(); - assertEquals( QuerySpace.Disposition.COLLECTION, collectionJoin.getRightHandSide().getDisposition() ); - assertFalse( iterator.hasNext() ); - em.close(); - } - - - @Test - public void testEmbeddedCollection() { - EntityManager em = getOrCreateEntityManager(); - EntityGraph eg = em.createEntityGraph( ExpressCompany.class ); - eg.addAttributeNodes( "shipAddresses" ); - - LoadPlan loadLoadPlan = buildLoadPlan( eg, GraphSemantic.LOAD, ExpressCompany.class ); //WTF name!!! - LoadPlanTreePrinter.INSTANCE.logTree( loadLoadPlan, new AliasResolutionContextImpl( sfi() ) ); - - QuerySpace querySpace = loadLoadPlan.getQuerySpaces().getRootQuerySpaces().iterator().next(); - Iterator iterator = querySpace.getJoins().iterator(); - assertTrue( iterator.hasNext() ); - Join collectionJoin = iterator.next(); - assertEquals( QuerySpace.Disposition.COLLECTION, collectionJoin.getRightHandSide().getDisposition() ); - assertFalse( iterator.hasNext() ); - - iterator = collectionJoin.getRightHandSide().getJoins().iterator(); - assertTrue( iterator.hasNext() ); - Join collectionElementJoin = iterator.next(); - assertFalse( iterator.hasNext() ); - assertEquals( QuerySpace.Disposition.COMPOSITE, collectionElementJoin.getRightHandSide().getDisposition() ); - - iterator = collectionElementJoin.getRightHandSide().getJoins().iterator(); - assertTrue( iterator.hasNext() ); - Join countryJoin = iterator.next(); - assertFalse( iterator.hasNext() ); - assertEquals( QuerySpace.Disposition.ENTITY, countryJoin.getRightHandSide().getDisposition() ); - - //---------------------------------------------------------------- - LoadPlan fetchLoadPlan = buildLoadPlan( eg, GraphSemantic.FETCH, ExpressCompany.class ); - LoadPlanTreePrinter.INSTANCE.logTree( fetchLoadPlan, new AliasResolutionContextImpl( sfi() ) ); - - - querySpace = fetchLoadPlan.getQuerySpaces().getRootQuerySpaces().iterator().next(); - iterator = querySpace.getJoins().iterator(); - assertTrue( iterator.hasNext() ); - collectionJoin = iterator.next(); - assertEquals( QuerySpace.Disposition.COLLECTION, collectionJoin.getRightHandSide().getDisposition() ); - assertFalse( iterator.hasNext() ); - - iterator = collectionJoin.getRightHandSide().getJoins().iterator(); - assertTrue( iterator.hasNext() ); - collectionElementJoin = iterator.next(); - assertFalse( iterator.hasNext() ); - assertEquals( QuerySpace.Disposition.COMPOSITE, collectionElementJoin.getRightHandSide().getDisposition() ); - - iterator = collectionElementJoin.getRightHandSide().getJoins().iterator(); - assertFalse( iterator.hasNext() ); - //---------------------------------------------------------------- - em.close(); - } - - - private SessionFactoryImplementor sfi() { - return entityManagerFactory().unwrap( SessionFactoryImplementor.class ); - } - - private LoadPlan buildLoadPlan(EntityGraph entityGraph, GraphSemantic mode, Class clazz) { - final LoadQueryInfluencers loadQueryInfluencers = new LoadQueryInfluencers( sfi() ); - final EffectiveEntityGraph effectiveEntityGraph = loadQueryInfluencers.getEffectiveEntityGraph(); - effectiveEntityGraph.applyGraph( ( RootGraphImplementor) entityGraph, mode ); - - final EntityPersister ep = (EntityPersister) sfi().getClassMetadata( clazz ); - AbstractLoadPlanBuildingAssociationVisitationStrategy strategy = GraphSemantic.FETCH == mode - ? new FetchGraphLoadPlanBuildingStrategy( - sfi(), - effectiveEntityGraph.getGraph(), - loadQueryInfluencers, - LockMode.NONE - ) : new LoadGraphLoadPlanBuildingStrategy( sfi(), loadQueryInfluencers, LockMode.NONE ); - return MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, ep ); - } - -} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/LoadingSmokeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/LoadingSmokeTests.java index ee3a9519cb..a43a005103 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/LoadingSmokeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/LoadingSmokeTests.java @@ -7,10 +7,9 @@ package org.hibernate.orm.test.loading; import org.hibernate.Hibernate; -import org.hibernate.loader.internal.SingleIdEntityLoaderStandardImpl; -import org.hibernate.loader.spi.SingleIdEntityLoader; +import org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl; +import org.hibernate.loader.ast.spi.SingleIdEntityLoader; import org.hibernate.persister.entity.AbstractEntityPersister; -import org.hibernate.persister.entity.EntityPersister; import org.hibernate.testing.orm.domain.StandardDomainModel; import org.hibernate.testing.orm.domain.gambit.BasicEntity; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java index 9b72b96f39..0c3447693a 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java @@ -22,7 +22,7 @@ import org.hibernate.Hibernate; import org.hibernate.LockOptions; import org.hibernate.engine.spi.LoadQueryInfluencers; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.loader.internal.MetamodelSelectBuilderProcess; +import org.hibernate.loader.ast.internal.LoaderSelectBuilder; import org.hibernate.metamodel.spi.DomainMetamodel; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.sql.ast.tree.from.TableGroup; @@ -30,12 +30,12 @@ import org.hibernate.sql.ast.tree.from.TableGroupJoin; import org.hibernate.sql.ast.tree.predicate.ComparisonPredicate; import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.SelectStatement; -import org.hibernate.sql.results.internal.domain.basic.BasicFetch; -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.EntityResult; -import org.hibernate.sql.results.spi.Fetch; +import org.hibernate.sql.results.graph.basic.BasicFetch; +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.entity.EntityResult; +import org.hibernate.sql.results.graph.Fetch; import org.hibernate.testing.orm.junit.DomainModel; import org.hibernate.testing.orm.junit.SessionFactory; @@ -67,7 +67,7 @@ public class MappedFetchTests { final DomainMetamodel domainModel = sessionFactory.getDomainModel(); final EntityPersister rootEntityDescriptor = domainModel.getEntityDescriptor( RootEntity.class ); - final SelectStatement sqlAst = MetamodelSelectBuilderProcess.createSelect( + final SelectStatement sqlAst = LoaderSelectBuilder.createSelect( rootEntityDescriptor, null, rootEntityDescriptor.getIdentifierMapping(), diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/graphs/EntityGraphLoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/graphs/EntityGraphLoadPlanBuilderTest.java new file mode 100644 index 0000000000..88adf5a55c --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/graphs/EntityGraphLoadPlanBuilderTest.java @@ -0,0 +1,427 @@ +/* + * 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.orm.test.loading.graphs; + +import java.util.Set; +import javax.persistence.ElementCollection; +import javax.persistence.Embeddable; +import javax.persistence.Embedded; +import javax.persistence.Entity; +import javax.persistence.EntityGraph; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +import org.hibernate.LockOptions; +import org.hibernate.engine.spi.EffectiveEntityGraph; +import org.hibernate.engine.spi.LoadQueryInfluencers; +import org.hibernate.graph.GraphSemantic; +import org.hibernate.graph.spi.RootGraphImplementor; +import org.hibernate.loader.ast.internal.LoaderSelectBuilder; +import org.hibernate.loader.plan.spi.EntityFetch; +import org.hibernate.metamodel.mapping.EntityValuedModelPart; +import org.hibernate.metamodel.mapping.PluralAttributeMapping; +import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.sql.ast.tree.from.FromClause; +import org.hibernate.sql.ast.tree.from.TableGroup; +import org.hibernate.sql.ast.tree.from.TableGroupJoin; +import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.results.graph.entity.internal.EntityFetchDelayedImpl; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.entity.EntityResult; +import org.hibernate.sql.results.graph.Fetch; + +import org.hibernate.testing.hamcrest.AssignableMatcher; +import org.hibernate.testing.hamcrest.CollectionMatchers; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; + +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; +import static org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty; +import static org.junit.Assert.assertThat; + +/** + * @author Strong Liu + * @author Steve Ebersole + */ +@DomainModel( + annotatedClasses = { + EntityGraphLoadPlanBuilderTest.Cat.class, + EntityGraphLoadPlanBuilderTest.Person.class, + EntityGraphLoadPlanBuilderTest.Country.class, + EntityGraphLoadPlanBuilderTest.Dog.class, + EntityGraphLoadPlanBuilderTest.ExpressCompany.class + } +) +@SessionFactory +public class EntityGraphLoadPlanBuilderTest { + + /** + * EntityGraph: + * + * Cat + * + * LoadPlan: + * + * Cat + */ + @Test + public void testBasicFetchLoadPlanBuilding(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Cat.class ); + + final SelectStatement sqlAst = buildSqlSelectAst( Cat.class, eg, GraphSemantic.FETCH, scope ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots().size(), is( 1 ) ); + final TableGroup rootTableGroup = fromClause.getRoots().get( 0 ); + assertThat( rootTableGroup.getTableGroupJoins(), CollectionMatchers.isEmpty() ); + + assertThat( sqlAst.getDomainResultDescriptors(), hasSize( 1 ) ); + final DomainResult domainResult = sqlAst.getDomainResultDescriptors().get( 0 ); + + assertThat( domainResult, instanceOf( EntityResult.class ) ); + final EntityResult entityResult = (EntityResult) domainResult; + + assertThat( + domainResult.getResultJavaTypeDescriptor().getJavaType(), + AssignableMatcher.assignableTo( Cat.class ) + ); + + assertThat( entityResult.getFetches(), hasSize( 1 ) ); + assertThat( entityResult.getFetches().get( 0 ), instanceOf( EntityFetchDelayedImpl.class ) ); + } + ); + } + + + /** + * EntityGraph: + * + * Cat + * owner -- Person + * + * LoadPlan: + * + * Cat + * owner -- Person + * address --- Address + */ + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testFetchLoadPlanBuildingWithSubgraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Cat.class ); + eg.addSubgraph( "owner", Person.class ); + + final SelectStatement sqlAst = buildSqlSelectAst( Cat.class, eg, GraphSemantic.FETCH, scope ); + + // Check the from-clause + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots().size(), is( 1 ) ); + final TableGroup rootTableGroup = fromClause.getRoots().get( 0 ); + assertThat( rootTableGroup.getTableGroupJoins(), hasSize( 1 ) ); + final TableGroupJoin ownerJoin = rootTableGroup.getTableGroupJoins().iterator().next(); + assertThat( ownerJoin, notNullValue() ); + assertThat( ownerJoin.getJoinedGroup().getModelPart(), instanceOf( EntityValuedModelPart.class ) ); + + + // Check the domain-result graph + assertThat( sqlAst.getDomainResultDescriptors(), hasSize( 1 ) ); + final DomainResult domainResult = sqlAst.getDomainResultDescriptors().get( 0 ); + assertThat( domainResult, instanceOf( EntityResult.class ) ); + final EntityResult catResult = (EntityResult) domainResult; + assertThat( catResult.getFetches(), hasSize( 1 ) ); + final Fetch fetch = catResult.getFetches().get( 0 ); + assertThat( fetch, instanceOf( EntityFetch.class ) ); + final EntityFetch ownerFetch = (EntityFetch) fetch; + assertThat( ownerFetch.getFetchedType().getName(), is( "owner" ) ); + assertThat( ownerFetch.getEntityPersister().getEntityName(), is( Person.class.getName() ) ); + } + ); + } + + /** + * EntityGraph: + * + * Cat + * + * LoadPlan: + * + * Cat + */ + @Test + public void testBasicLoadLoadPlanBuilding(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Cat.class ); + + final SelectStatement sqlAst = buildSqlSelectAst( Cat.class, eg, GraphSemantic.LOAD, scope ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup rootTableGroup = fromClause.getRoots().get( 0 ); + assertThat( rootTableGroup.getTableGroupJoins(), isEmpty() ); + + assertThat( sqlAst.getDomainResultDescriptors(), hasSize( 1 ) ); + final DomainResult domainResult = sqlAst.getDomainResultDescriptors().get( 0 ); + assertThat( domainResult, instanceOf( EntityResult.class ) ); + assertThat( domainResult.getResultJavaTypeDescriptor().getJavaType().getName(), is( Cat.class.getName() ) ); + final EntityResult entityResult = (EntityResult) domainResult; + assertThat( entityResult.getFetches(), hasSize( 1 ) ); + assertThat( entityResult.getFetches().get( 0 ), instanceOf( EntityFetchDelayedImpl.class ) ); + } + ); + } + + /** + *EntityGraph: + * + * Cat + * owner -- Person + * + * LoadPlan: + * + * Cat + * owner -- Person + * address --- Address + * country -- Country + */ + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testLoadLoadPlanBuildingWithSubgraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Cat.class ); + eg.addSubgraph( "owner", Person.class ); + + final SelectStatement sqlAst = buildSqlSelectAst( Cat.class, eg, GraphSemantic.LOAD, scope ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup rootTableGroup = fromClause.getRoots().get( 0 ); + assertThat( rootTableGroup.getTableGroupJoins(), hasSize( 1 ) ); + + assertThat( sqlAst.getDomainResultDescriptors(), hasSize( 1 ) ); + final DomainResult domainResult = sqlAst.getDomainResultDescriptors().get( 0 ); + assertThat( domainResult, instanceOf( EntityResult.class ) ); + assertThat( ( (EntityResult) domainResult ).getFetches(), hasSize( 1 ) ); + final Fetch fetch = ( (EntityResult) domainResult ).getFetches().get( 0 ); + assertThat( fetch, instanceOf( EntityFetch.class ) ); + final EntityFetch ownerFetch = (EntityFetch) fetch; + assertThat( ownerFetch.getFetchedType().getName(), is( "owner" ) ); + assertThat( ownerFetch.getEntityPersister().getEntityName(), is( Person.class.getName() ) ); + + // todo (6.0) : check the sub-fetches for Address + } + ); + } + + + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testBasicElementCollectionsLoadGraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Dog.class ); + eg.addAttributeNodes( "favorites" ); + + final SelectStatement sqlAst = buildSqlSelectAst( Dog.class, eg, GraphSemantic.LOAD, scope ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup root = fromClause.getRoots().get( 0 ); + assertThat( root.getTableGroupJoins(), hasSize( 1 ) ); + final TableGroup joinedGroup = root.getTableGroupJoins().iterator().next().getJoinedGroup(); + assertThat( joinedGroup.getModelPart(), instanceOf( PluralAttributeMapping.class ) ); + final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) joinedGroup.getModelPart(); + assertThat( pluralAttributeMapping.getAttributeName(), is( "favorites" ) ); + } + ); + } + + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testBasicElementCollectionsFetchGraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( Dog.class ); + eg.addAttributeNodes( "favorites" ); + + final SelectStatement sqlAst = buildSqlSelectAst( Dog.class, eg, GraphSemantic.FETCH, scope ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup root = fromClause.getRoots().get( 0 ); + assertThat( root.getTableGroupJoins(), hasSize( 1 ) ); + final TableGroup joinedGroup = root.getTableGroupJoins().iterator().next().getJoinedGroup(); + assertThat( joinedGroup.getModelPart(), instanceOf( PluralAttributeMapping.class ) ); + final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) joinedGroup.getModelPart(); + assertThat( pluralAttributeMapping.getAttributeName(), is( "favorites" ) ); + } + ); + } + + + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testEmbeddedCollectionLoadSubgraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( ExpressCompany.class ); + eg.addAttributeNodes( "shipAddresses" ); + + final SelectStatement sqlAst = buildSqlSelectAst( + ExpressCompany.class, + eg, GraphSemantic.LOAD, + scope + ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup root = fromClause.getRoots().get( 0 ); + assertThat( root.getTableGroupJoins(), hasSize( 1 ) ); + final TableGroup joinedGroup = root.getTableGroupJoins().iterator().next().getJoinedGroup(); + assertThat( joinedGroup.getModelPart(), instanceOf( PluralAttributeMapping.class ) ); + final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) joinedGroup.getModelPart(); + assertThat( pluralAttributeMapping.getAttributeName(), is( "shipAddresses" ) ); + assertThat( joinedGroup.getTableGroupJoins(), isEmpty() ); + + +// QuerySpace querySpace = loadLoadPlan.getQuerySpaces().getRootQuerySpaces().iterator().next(); +// Iterator iterator = querySpace.getJoins().iterator(); +// assertTrue( iterator.hasNext() ); +// Join collectionJoin = iterator.next(); +// assertEquals( QuerySpace.Disposition.COLLECTION, collectionJoin.getRightHandSide().getDisposition() ); +// assertFalse( iterator.hasNext() ); +// +// iterator = collectionJoin.getRightHandSide().getJoins().iterator(); +// assertTrue( iterator.hasNext() ); +// Join collectionElementJoin = iterator.next(); +// assertFalse( iterator.hasNext() ); +// assertEquals( QuerySpace.Disposition.COMPOSITE, collectionElementJoin.getRightHandSide().getDisposition() ); +// +// iterator = collectionElementJoin.getRightHandSide().getJoins().iterator(); +// assertTrue( iterator.hasNext() ); +// Join countryJoin = iterator.next(); +// assertFalse( iterator.hasNext() ); +// assertEquals( QuerySpace.Disposition.ENTITY, countryJoin.getRightHandSide().getDisposition() ); + + } + ); + } + + @Test + @FailureExpected( jiraKey = "HHH-13756", reason = "EntityGraph support not yet implemented" ) + public void testEmbeddedCollectionFetchSubgraph(SessionFactoryScope scope) { + scope.inTransaction( + em -> { + EntityGraph eg = em.createEntityGraph( ExpressCompany.class ); + eg.addAttributeNodes( "shipAddresses" ); + + final SelectStatement sqlAst = buildSqlSelectAst( + ExpressCompany.class, + eg, GraphSemantic.FETCH, + scope + ); + + final FromClause fromClause = sqlAst.getQuerySpec().getFromClause(); + assertThat( fromClause.getRoots(), hasSize( 1 ) ); + final TableGroup root = fromClause.getRoots().get( 0 ); + assertThat( root.getTableGroupJoins(), hasSize( 1 ) ); + final TableGroup joinedGroup = root.getTableGroupJoins().iterator().next().getJoinedGroup(); + assertThat( joinedGroup.getModelPart(), instanceOf( PluralAttributeMapping.class ) ); + final PluralAttributeMapping pluralAttributeMapping = (PluralAttributeMapping) joinedGroup.getModelPart(); + assertThat( pluralAttributeMapping.getAttributeName(), is( "shipAddresses" ) ); + assertThat( joinedGroup.getTableGroupJoins(), isEmpty() ); + } + ); + } + + private SelectStatement buildSqlSelectAst( + Class entityType, + EntityGraph entityGraph, + GraphSemantic mode, + SessionFactoryScope scope) { + final EntityPersister entityDescriptor = scope.getSessionFactory().getDomainModel().getEntityDescriptor( entityType ); + + final LoadQueryInfluencers loadQueryInfluencers = new LoadQueryInfluencers( scope.getSessionFactory() ); + final EffectiveEntityGraph effectiveEntityGraph = loadQueryInfluencers.getEffectiveEntityGraph(); + effectiveEntityGraph.applyGraph( ( RootGraphImplementor) entityGraph, mode ); + + return LoaderSelectBuilder.createSelect( + entityDescriptor, + null, + entityDescriptor.getIdentifierMapping(), + null, + 1, + loadQueryInfluencers, + LockOptions.READ, + jdbcParameter -> {}, + scope.getSessionFactory() + ); + } + + + + @Entity + public static class Dog { + @Id + String name; + @ElementCollection + Set favorites; + } + + @Entity + public static class Cat { + @Id + String name; + @ManyToOne(fetch = FetchType.LAZY) + Person owner; + + } + + @Entity + public static class Person { + @Id + String name; + @OneToMany(mappedBy = "owner") + Set pets; + @Embedded + Address homeAddress; + } + + @Embeddable + public static class Address { + @ManyToOne + Country country; + } + + @Entity + public static class ExpressCompany { + @Id + String name; + @ElementCollection + Set
shipAddresses; + } + + @Entity + public static class Country { + @Id + String name; + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/plan/LoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/plan/LoadPlanBuilderTest.java new file mode 100644 index 0000000000..02c3058c02 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/plan/LoadPlanBuilderTest.java @@ -0,0 +1,150 @@ +/* + * 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.orm.test.loading.plan; + +import java.util.List; +import javax.persistence.CascadeType; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.OneToMany; + +import org.hibernate.LockOptions; +import org.hibernate.NotYetImplementedFor6Exception; +import org.hibernate.engine.spi.LoadQueryInfluencers; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.loader.ast.internal.SingleIdEntityLoaderStandardImpl; +import org.hibernate.loader.ast.internal.SingleIdLoadPlan; +import org.hibernate.loader.ast.internal.SingleKeyCollectionLoader; +import org.hibernate.metamodel.mapping.PluralAttributeMapping; +import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultGraphPrinter; +import org.hibernate.sql.results.graph.Fetch; +import org.hibernate.sql.results.graph.collection.internal.CollectionDomainResult; +import org.hibernate.sql.results.graph.entity.EntityResult; + +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.FailureExpected; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.hibernate.testing.hamcrest.CollectionMatchers.hasSize; +import static org.hibernate.testing.hamcrest.CollectionMatchers.isEmpty; +import static org.junit.Assert.assertThat; + +/** + * @author Steve Ebersole + */ +@DomainModel( + annotatedClasses = { LoadPlanBuilderTest.Message.class, LoadPlanBuilderTest.Poster.class } +) +@SessionFactory +public class LoadPlanBuilderTest { + @Test + public void testSimpleBuild(SessionFactoryScope scope) { + final SessionFactoryImplementor sessionFactory = scope.getSessionFactory(); + final EntityPersister entityDescriptor = sessionFactory.getDomainModel().getEntityDescriptor( Message.class ); + + final SingleIdEntityLoaderStandardImpl loader = new SingleIdEntityLoaderStandardImpl( + entityDescriptor, + sessionFactory + ); + + final SingleIdLoadPlan loadPlan = loader.resolveLoadPlan( + LockOptions.READ, + LoadQueryInfluencers.NONE, + sessionFactory + ); + + assertThat( + loadPlan.getSqlAst().getDomainResultDescriptors(), + hasSize( 1 ) + + ); + final DomainResult domainResult = loadPlan.getSqlAst().getDomainResultDescriptors().get( 0 ); + assertThat( domainResult, instanceOf( EntityResult.class ) ); + final EntityResult entityResult = (EntityResult) domainResult; + assertThat( entityResult.getFetches(), hasSize( 2 ) ); + + final Fetch txtFetch = entityResult.getFetches().get( 0 ); + + final Fetch posterFetch = entityResult.getFetches().get( 1 ); + } + + @Test + @FailureExpected( reason = "Cascade-driven DomainResult graph building not yet implemented" ) + public void testCascadeBasedBuild() { + throw new NotYetImplementedFor6Exception( "Cascade-driven DomainResult graph building not yet implemented" ); +// EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class); +// CascadeStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new CascadeStyleLoadPlanBuildingAssociationVisitationStrategy( +// CascadingActions.MERGE, +// sessionFactory(), +// LoadQueryInfluencers.NONE, +// LockMode.NONE +// ); +// LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, ep ); +// assertFalse( plan.hasAnyScalarReturns() ); +// assertEquals( 1, plan.getReturns().size() ); +// Return rtn = plan.getReturns().get( 0 ); +// EntityReturn entityReturn = ExtraAssertions.assertTyping( EntityReturn.class, rtn ); +// assertNotNull( entityReturn.getFetches() ); +// assertEquals( 1, entityReturn.getFetches().length ); +// Fetch fetch = entityReturn.getFetches()[0]; +// EntityFetch entityFetch = ExtraAssertions.assertTyping( EntityFetch.class, fetch ); +// assertNotNull( entityFetch.getFetches() ); +// assertEquals( 0, entityFetch.getFetches().length ); +// +// LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sessionFactory() ) ); + } + + @Test + public void testCollectionInitializerCase(SessionFactoryScope scope) { + final SessionFactoryImplementor sessionFactory = scope.getSessionFactory(); + final EntityPersister posterEntityDescriptor = sessionFactory.getDomainModel().getEntityDescriptor( Poster.class ); + final PluralAttributeMapping messages = (PluralAttributeMapping) posterEntityDescriptor.findAttributeMapping( "messages" ); + + final SingleKeyCollectionLoader loader = new SingleKeyCollectionLoader( + messages, + LoadQueryInfluencers.NONE, + sessionFactory + ); + + assertThat( loader.getSqlAst().getDomainResultDescriptors(), hasSize( 1 ) ); + assertThat( loader.getSqlAst().getDomainResultDescriptors().get( 0 ), instanceOf( CollectionDomainResult.class ) ); + final CollectionDomainResult domainResult = (CollectionDomainResult) loader.getSqlAst() + .getDomainResultDescriptors() + .get( 0 ); + + DomainResultGraphPrinter.print( loader.getSqlAst().getDomainResultDescriptors() ); + + assertThat( domainResult.getFetches(), isEmpty() ); + } + + @Entity( name = "Message" ) + public static class Message { + @Id + private Integer mid; + private String msgTxt; + @ManyToOne( cascade = CascadeType.MERGE ) + @JoinColumn + private Poster poster; + } + + @Entity( name = "Poster" ) + public static class Poster { + @Id + private Integer pid; + private String name; + @OneToMany(mappedBy = "poster") + private List messages; + } + +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/BasicCriteriaExecutionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/BasicCriteriaExecutionTests.java index 76df143e15..34ba03f478 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/BasicCriteriaExecutionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/criteria/BasicCriteriaExecutionTests.java @@ -16,14 +16,12 @@ import javax.persistence.criteria.CriteriaQuery; import javax.persistence.criteria.ParameterExpression; import javax.persistence.criteria.Root; -import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.criteria.HibernateCriteriaBuilder; import org.hibernate.query.criteria.JpaCriteriaQuery; import org.hibernate.query.criteria.JpaRoot; import org.hibernate.query.spi.QueryParameterImplementor; -import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.tree.expression.SqmParameter; -import org.hibernate.sql.exec.spi.JdbcParameter; +import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase; import org.junit.Test; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/BaseSqmUnitTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/BaseSqmUnitTest.java index 0b4bde52f3..67ee1485c5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/BaseSqmUnitTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/sqm/BaseSqmUnitTest.java @@ -9,7 +9,7 @@ package org.hibernate.orm.test.query.sqm; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.AvailableSettings; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.loader.spi.AfterLoadAction; +import org.hibernate.loader.ast.spi.AfterLoadAction; import org.hibernate.metamodel.spi.MetamodelImplementor; import org.hibernate.query.sqm.tree.select.SqmSelectStatement; import org.hibernate.service.ServiceRegistry; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/ast/SmokeTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/ast/SmokeTests.java index b89e4dc5cf..e8aad8d0cc 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/ast/SmokeTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/ast/SmokeTests.java @@ -29,10 +29,10 @@ import org.hibernate.sql.ast.tree.select.SelectClause; import org.hibernate.sql.ast.tree.select.SelectStatement; import org.hibernate.sql.exec.spi.JdbcSelect; import org.hibernate.sql.results.internal.SqlSelectionImpl; -import org.hibernate.sql.results.internal.domain.basic.BasicResult; -import org.hibernate.sql.results.internal.domain.basic.BasicResultAssembler; -import org.hibernate.sql.results.spi.DomainResult; -import org.hibernate.sql.results.spi.DomainResultAssembler; +import org.hibernate.sql.results.graph.basic.BasicResult; +import org.hibernate.sql.results.graph.basic.BasicResultAssembler; +import org.hibernate.sql.results.graph.DomainResult; +import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.type.CustomType; import org.hibernate.type.EnumType; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/AbstractResultTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/AbstractResultTests.java new file mode 100644 index 0000000000..9108f24f52 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/AbstractResultTests.java @@ -0,0 +1,45 @@ +/* + * 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.orm.test.sql.results; + +import org.hibernate.engine.spi.LoadQueryInfluencers; +import org.hibernate.engine.spi.SessionFactoryImplementor; +import org.hibernate.query.spi.QueryEngine; +import org.hibernate.query.spi.QueryOptions; +import org.hibernate.query.spi.QueryParameterBindings; +import org.hibernate.query.sqm.internal.DomainParameterXref; +import org.hibernate.query.sqm.sql.SqmSelectTranslation; +import org.hibernate.query.sqm.sql.SqmSelectTranslator; +import org.hibernate.query.sqm.sql.SqmTranslatorFactory; +import org.hibernate.query.sqm.tree.select.SqmSelectStatement; +import org.hibernate.sql.ast.tree.select.SelectStatement; + +/** + * @author Steve Ebersole + */ +public class AbstractResultTests { + protected SelectStatement interpret(String hql, SessionFactoryImplementor sessionFactory) { + return interpret( hql, QueryParameterBindings.NO_PARAM_BINDINGS, sessionFactory ); + } + + protected SelectStatement interpret(String hql, QueryParameterBindings parameterBindings, SessionFactoryImplementor sessionFactory) { + final QueryEngine queryEngine = sessionFactory.getQueryEngine(); + + final SqmSelectStatement sqm = (SqmSelectStatement) queryEngine.getHqlTranslator().translate( hql ); + + final SqmTranslatorFactory sqmTranslatorFactory = queryEngine.getSqmTranslatorFactory(); + final SqmSelectTranslator sqmConverter = sqmTranslatorFactory.createSelectTranslator( + QueryOptions.NONE, + DomainParameterXref.from( sqm ), + parameterBindings, + LoadQueryInfluencers.NONE, + sessionFactory + ); + + return sqmConverter.translate( sqm ).getSqlAst(); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/BasicResultTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/BasicResultTests.java new file mode 100644 index 0000000000..2fc2987a09 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/BasicResultTests.java @@ -0,0 +1,34 @@ +/* + * 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.orm.test.sql.results; + +import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.results.graph.DomainResultGraphPrinter; + +import org.hibernate.testing.orm.domain.StandardDomainModel; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +/** + * @author Steve Ebersole + */ +@SuppressWarnings("WeakerAccess") +@DomainModel( standardModels = StandardDomainModel.GAMBIT ) +@SessionFactory( exportSchema = false ) +public class BasicResultTests extends AbstractResultTests { + @Test + public void simpleTest(SessionFactoryScope scope) { + final SelectStatement sqlAst = interpret( + "select s.id, s.someString, s.someLong from SimpleEntity s", + scope.getSessionFactory() + ); + DomainResultGraphPrinter.print( sqlAst.getDomainResultDescriptors() ); + + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/EmbeddableResultTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/EmbeddableResultTests.java new file mode 100644 index 0000000000..48f70d13b4 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/sql/results/EmbeddableResultTests.java @@ -0,0 +1,33 @@ +/* + * 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.orm.test.sql.results; + +import org.hibernate.sql.ast.tree.select.SelectStatement; +import org.hibernate.sql.results.graph.DomainResultGraphPrinter; + +import org.hibernate.testing.orm.domain.StandardDomainModel; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +/** + * @author Steve Ebersole + */ +@SuppressWarnings("WeakerAccess") +@DomainModel( standardModels = StandardDomainModel.GAMBIT ) +@SessionFactory( exportSchema = false ) +public class EmbeddableResultTests extends AbstractResultTests { + @Test + public void simpleTest(SessionFactoryScope scope) { + final SelectStatement interpretation = interpret( + "select e from EntityOfComposites e join fetch e.component c join fetch c.nested", + scope.getSessionFactory() + ); + DomainResultGraphPrinter.print( interpretation.getDomainResultDescriptors() ); + } +} diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanBuilderTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanBuilderTest.java deleted file mode 100644 index 83e693289b..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanBuilderTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.loadplans.plans; - -import java.util.List; -import javax.persistence.CascadeType; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; - -import org.hibernate.LockMode; -import org.hibernate.engine.spi.CascadingActions; -import org.hibernate.engine.spi.LoadQueryInfluencers; -import org.hibernate.loader.plan.build.internal.CascadeStyleLoadPlanBuildingAssociationVisitationStrategy; -import org.hibernate.loader.plan.build.internal.FetchStyleLoadPlanBuildingAssociationVisitationStrategy; -import org.hibernate.loader.plan.build.spi.LoadPlanTreePrinter; -import org.hibernate.loader.plan.build.spi.MetamodelDrivenLoadPlanBuilder; -import org.hibernate.loader.plan.exec.internal.AliasResolutionContextImpl; -import org.hibernate.loader.plan.spi.CollectionReturn; -import org.hibernate.loader.plan.spi.EntityFetch; -import org.hibernate.loader.plan.spi.EntityReference; -import org.hibernate.loader.plan.spi.EntityReturn; -import org.hibernate.loader.plan.spi.Fetch; -import org.hibernate.loader.plan.spi.LoadPlan; -import org.hibernate.loader.plan.spi.Return; -import org.hibernate.persister.collection.CollectionPersister; -import org.hibernate.persister.entity.EntityPersister; - -import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; -import org.hibernate.testing.junit4.ExtraAssertions; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; - -/** - * @author Steve Ebersole - */ -public class LoadPlanBuilderTest extends BaseCoreFunctionalTestCase { - @Override - protected Class[] getAnnotatedClasses() { - return new Class[] { Message.class, Poster.class }; - } - - @Test - public void testSimpleBuild() { - EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class); - FetchStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new FetchStyleLoadPlanBuildingAssociationVisitationStrategy( - sessionFactory(), - LoadQueryInfluencers.NONE, - LockMode.NONE - ); - LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, ep ); - assertFalse( plan.hasAnyScalarReturns() ); - assertEquals( 1, plan.getReturns().size() ); - Return rtn = plan.getReturns().get( 0 ); - EntityReturn entityReturn = ExtraAssertions.assertTyping( EntityReturn.class, rtn ); - assertNotNull( entityReturn.getFetches() ); - assertEquals( 1, entityReturn.getFetches().length ); - Fetch fetch = entityReturn.getFetches()[0]; - EntityFetch entityFetch = ExtraAssertions.assertTyping( EntityFetch.class, fetch ); - assertNotNull( entityFetch.getFetches() ); - assertEquals( 0, entityFetch.getFetches().length ); - - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sessionFactory() ) ); - } - - @Test - public void testCascadeBasedBuild() { - EntityPersister ep = (EntityPersister) sessionFactory().getClassMetadata(Message.class); - CascadeStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new CascadeStyleLoadPlanBuildingAssociationVisitationStrategy( - CascadingActions.MERGE, - sessionFactory(), - LoadQueryInfluencers.NONE, - LockMode.NONE - ); - LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, ep ); - assertFalse( plan.hasAnyScalarReturns() ); - assertEquals( 1, plan.getReturns().size() ); - Return rtn = plan.getReturns().get( 0 ); - EntityReturn entityReturn = ExtraAssertions.assertTyping( EntityReturn.class, rtn ); - assertNotNull( entityReturn.getFetches() ); - assertEquals( 1, entityReturn.getFetches().length ); - Fetch fetch = entityReturn.getFetches()[0]; - EntityFetch entityFetch = ExtraAssertions.assertTyping( EntityFetch.class, fetch ); - assertNotNull( entityFetch.getFetches() ); - assertEquals( 0, entityFetch.getFetches().length ); - - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sessionFactory() ) ); - } - - @Test - public void testCollectionInitializerCase() { - CollectionPersister cp = sessionFactory().getCollectionPersister( Poster.class.getName() + ".messages" ); - FetchStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new FetchStyleLoadPlanBuildingAssociationVisitationStrategy( - sessionFactory(), - LoadQueryInfluencers.NONE, - LockMode.NONE - ); - LoadPlan plan = MetamodelDrivenLoadPlanBuilder.buildRootCollectionLoadPlan( strategy, cp ); - assertFalse( plan.hasAnyScalarReturns() ); - assertEquals( 1, plan.getReturns().size() ); - Return rtn = plan.getReturns().get( 0 ); - CollectionReturn collectionReturn = ExtraAssertions.assertTyping( CollectionReturn.class, rtn ); - - assertNotNull( collectionReturn.getElementGraph() ); - assertNotNull( collectionReturn.getElementGraph().getFetches() ); - // the collection Message elements are fetched, but Message.poster is not fetched - // (because that collection is owned by that Poster) - assertEquals( 0, collectionReturn.getElementGraph().getFetches().length ); - EntityReference entityReference = ExtraAssertions.assertTyping( EntityReference.class, collectionReturn.getElementGraph() ); - assertNotNull( entityReference.getFetches() ); - assertEquals( 0, entityReference.getFetches().length ); - - LoadPlanTreePrinter.INSTANCE.logTree( plan, new AliasResolutionContextImpl( sessionFactory() ) ); - } - - @Entity( name = "Message" ) - public static class Message { - @Id - private Integer mid; - private String msgTxt; - @ManyToOne( cascade = CascadeType.MERGE ) - @JoinColumn - private Poster poster; - } - - @Entity( name = "Poster" ) - public static class Poster { - @Id - private Integer pid; - private String name; - @OneToMany(mappedBy = "poster") - private List messages; - } - -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionHelper.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionHelper.java deleted file mode 100644 index 3f5dba8f94..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionHelper.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.loadplans.plans; - -import org.hibernate.LockMode; -import org.hibernate.LockOptions; -import org.hibernate.engine.spi.LoadQueryInfluencers; -import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.loader.JoinWalker; -import org.hibernate.loader.entity.EntityJoinWalker; -import org.hibernate.loader.plan.build.internal.FetchStyleLoadPlanBuildingAssociationVisitationStrategy; -import org.hibernate.loader.plan.build.spi.MetamodelDrivenLoadPlanBuilder; -import org.hibernate.loader.plan.exec.internal.BatchingLoadQueryDetailsFactory; -import org.hibernate.loader.plan.exec.query.internal.QueryBuildingParametersImpl; -import org.hibernate.loader.plan.exec.query.spi.QueryBuildingParameters; -import org.hibernate.loader.plan.exec.spi.LoadQueryDetails; -import org.hibernate.loader.plan.spi.LoadPlan; -import org.hibernate.persister.entity.OuterJoinLoadable; - -/** - * Perform assertions based on a LoadPlan, specifically against the outputs/expectations of the legacy Loader approach. - *

- * Mainly this is intended to be a transitory set of help since it is expected that Loader will go away replaced by - * LoadPlans, QueryBuilders and ResultSetProcessors. For now I want to make sure that the outputs (e.g., the SQL, - * the extraction aliases) are the same given the same input. That makes sure we have the best possibility of success - * in designing and implementing the "replacement parts". - * - * @author Steve Ebersole - */ -public class LoadPlanStructureAssertionHelper { - /** - * Singleton access to the helper - */ - public static final LoadPlanStructureAssertionHelper INSTANCE = new LoadPlanStructureAssertionHelper(); - - /** - * Performs a basic comparison. Builds a LoadPlan for the given persister and compares it against the - * expectations according to the Loader/Walker corollary. - * - * @param sf The SessionFactory - * @param persister The entity persister for which to build a LoadPlan and compare against the Loader/Walker - * expectations. - */ - public void performBasicComparison(SessionFactoryImplementor sf, OuterJoinLoadable persister) { - // todo : allow these to be passed in by tests? - final LoadQueryInfluencers influencers = LoadQueryInfluencers.NONE; - final LockMode lockMode = LockMode.NONE; - final int batchSize = 1; - - // legacy Loader-based contracts... - final EntityJoinWalker walker = new EntityJoinWalker( - persister, - persister.getKeyColumnNames(), - batchSize, - lockMode, - sf, - influencers - ); -// final EntityLoader loader = new EntityLoader( persister, lockMode, sf, influencers ); - - LoadPlan plan = buildLoadPlan( sf, persister, influencers, lockMode ); - LoadQueryDetails details = BatchingLoadQueryDetailsFactory.INSTANCE.makeEntityLoadQueryDetails( - plan, - persister.getKeyColumnNames(), - new QueryBuildingParametersImpl( - influencers, - batchSize, - lockMode, - null - - ), - sf - ); - - compare( walker, details ); - } - - public LoadPlan buildLoadPlan( - SessionFactoryImplementor sf, - OuterJoinLoadable persister, - LoadQueryInfluencers influencers, - LockMode lockMode) { - FetchStyleLoadPlanBuildingAssociationVisitationStrategy strategy = new FetchStyleLoadPlanBuildingAssociationVisitationStrategy( - sf, - influencers, - lockMode - ); - return MetamodelDrivenLoadPlanBuilder.buildRootEntityLoadPlan( strategy, persister ); - } - - public LoadPlan buildLoadPlan(SessionFactoryImplementor sf, OuterJoinLoadable persister) { - return buildLoadPlan( sf, persister, LoadQueryInfluencers.NONE, LockMode.NONE ); - } - - private void compare(JoinWalker walker, LoadQueryDetails details) { - System.out.println( "------ SQL -----------------------------------------------------------------" ); - System.out.println( "WALKER : " + walker.getSQLString() ); - System.out.println( "LOAD-PLAN : " + details.getSqlStatement() ); - System.out.println( "----------------------------------------------------------------------------" ); - System.out.println( ); - System.out.println( "------ SUFFIXES ------------------------------------------------------------" ); - System.out.println( "WALKER : " + String.join( ", ", walker.getSuffixes() ) + " : " - + String.join( ", ", walker.getCollectionSuffixes() ) ); - System.out.println( "----------------------------------------------------------------------------" ); - System.out.println( ); - } -} diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java deleted file mode 100644 index e16491bde1..0000000000 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Hibernate, Relational Persistence for Idiomatic Java - * - * License: GNU Lesser General Public License (LGPL), version 2.1 or later. - * See the lgpl.txt file in the root directory or . - */ -package org.hibernate.test.loadplans.plans; - -import org.hibernate.cfg.Configuration; -import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.loader.plan.build.internal.returns.CollectionFetchableElementEntityGraph; -import org.hibernate.loader.plan.spi.BidirectionalEntityReference; -import org.hibernate.loader.plan.spi.CollectionAttributeFetch; -import org.hibernate.loader.plan.spi.EntityFetch; -import org.hibernate.loader.plan.spi.EntityReturn; -import org.hibernate.loader.plan.spi.FetchSource; -import org.hibernate.loader.plan.spi.LoadPlan; -import org.hibernate.persister.entity.OuterJoinLoadable; - -import org.hibernate.testing.junit4.BaseUnitTestCase; -import org.hibernate.test.annotations.Country; -import org.hibernate.test.annotations.cid.keymanytoone.Card; -import org.hibernate.test.annotations.cid.keymanytoone.CardField; -import org.hibernate.test.annotations.cid.keymanytoone.Key; -import org.hibernate.test.annotations.cid.keymanytoone.PrimaryKey; -import org.hibernate.test.annotations.collectionelement.Boy; -import org.hibernate.test.annotations.collectionelement.Matrix; -import org.hibernate.test.annotations.collectionelement.TestCourse; -import org.hibernate.test.loadplans.process.EncapsulatedCompositeIdResultSetProcessorTest; -import org.junit.Test; - -import static junit.framework.Assert.assertNotNull; -import static org.hibernate.testing.junit4.ExtraAssertions.assertTyping; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; - -//import org.hibernate.loader.plan.spi.BidirectionalEntityFetch; - -/** - * Used to assert that "fetch graphs" between JoinWalker and LoadPlan are same. - * - * @author Steve Ebersole - */ -public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { - @Test - public void testJoinedOneToOne() { - // tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest - Configuration cfg = new Configuration(); - cfg.addResource( "org/hibernate/test/onetoone/joined/Person.hbm.xml" ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { -// doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.joined.Person.class ) ); - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.joined.Entity.class ) ); - -// doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.joined.Address.class ) ); - } - finally { - sf.close(); - } - } - - @Test - public void testSpecialOneToOne() { - // tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest - Configuration cfg = new Configuration(); - cfg.addResource( "org/hibernate/test/onetoone/formula/Person.hbm.xml" ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.onetoone.formula.Person.class ) ); - } - finally { - sf.close(); - } - } - - @Test - public void testEncapsulatedCompositeIdNoFetches1() { - // CardField is an entity with a composite identifier mapped via a @EmbeddedId class (CardFieldPK) defining - // a @ManyToOne - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( EncapsulatedCompositeIdResultSetProcessorTest.CardField.class ); - cfg.addAnnotatedClass( EncapsulatedCompositeIdResultSetProcessorTest.Card.class ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( EncapsulatedCompositeIdResultSetProcessorTest.CardField.class ) ); - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( EncapsulatedCompositeIdResultSetProcessorTest.Card.class ) ); - } - finally { - sf.close(); - } - } - - @Test - public void testEncapsulatedCompositeIdNoFetches2() { - // Parent is an entity with a composite identifier mapped via a @EmbeddedId class (ParentPK) which is defined - // using just basic types (strings, ints, etc) - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( EncapsulatedCompositeIdResultSetProcessorTest.Parent.class ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( EncapsulatedCompositeIdResultSetProcessorTest.Parent.class ) ); - } - finally { - sf.close(); - } - } - - @Test - public void testEncapsulatedCompositeIdWithFetches1() { - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( Card.class ); - cfg.addAnnotatedClass( CardField.class ); - cfg.addAnnotatedClass( Key.class ); - cfg.addAnnotatedClass( PrimaryKey.class ); - - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - final OuterJoinLoadable cardFieldPersister = (OuterJoinLoadable) sf.getClassMetadata( CardField.class ); - doCompare( sf, cardFieldPersister ); - - final LoadPlan loadPlan = LoadPlanStructureAssertionHelper.INSTANCE.buildLoadPlan( sf, cardFieldPersister ); - assertEquals( LoadPlan.Disposition.ENTITY_LOADER, loadPlan.getDisposition() ); - assertEquals( 1, loadPlan.getReturns().size() ); - final EntityReturn cardFieldReturn = assertTyping( EntityReturn.class, loadPlan.getReturns().get( 0 ) ); - assertEquals( 0, cardFieldReturn.getFetches().length ); - - // CardField defines a composite pk with 2 many-to-ones : Card and Key (the id description acts as the composite); - // because it is an @EmbeddedId, the ID provided by the application is used "as is" - // and fetches are not included in the load plan. - assertFalse( cardFieldReturn.getIdentifierDescription().hasFetches() ); - - // we need the readers ordered in a certain manner. Here specifically: Fetch(Card), Fetch(Key), Return(CardField) - // - // additionally, we need Fetch(Card) and Fetch(Key) to be hydrated/semi-resolved before attempting to - // resolve the EntityKey for Return(CardField) - // - // together those sound like argument enough to continue keeping readers for "identifier fetches" as part of - // a special "identifier reader". generated aliases could help here too to remove cyclic-ness from the graph. - // but at any rate, we need to know still when this becomes circularity - } - finally { - sf.close(); - } - } - - @Test - public void testEncapsulatedCompositeIdWithFetches2() { - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( Card.class ); - cfg.addAnnotatedClass( CardField.class ); - cfg.addAnnotatedClass( Key.class ); - cfg.addAnnotatedClass( PrimaryKey.class ); - - final SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - final OuterJoinLoadable cardPersister = (OuterJoinLoadable) sf.getClassMetadata( Card.class ); - doCompare( sf, cardPersister ); - - final LoadPlan cardLoadPlan = LoadPlanStructureAssertionHelper.INSTANCE.buildLoadPlan( sf, cardPersister ); - assertEquals( LoadPlan.Disposition.ENTITY_LOADER, cardLoadPlan.getDisposition() ); - assertEquals( 1, cardLoadPlan.getReturns().size() ); - - // Check the root EntityReturn(Card) - final EntityReturn cardReturn = assertTyping( EntityReturn.class, cardLoadPlan.getReturns().get( 0 ) ); - assertFalse( cardReturn.getIdentifierDescription().hasFetches() ); - - // Card should have one fetch, the fields collection - assertEquals( 1, cardReturn.getFetches().length ); - final CollectionAttributeFetch fieldsFetch = assertTyping( CollectionAttributeFetch.class, cardReturn.getFetches()[0] ); - assertNotNull( fieldsFetch.getElementGraph() ); - - // the Card.fields collection has entity elements of type CardField... - final CollectionFetchableElementEntityGraph cardFieldElementGraph = assertTyping( CollectionFetchableElementEntityGraph.class, fieldsFetch.getElementGraph() ); - // CardField should have no fetches - assertEquals( 0, cardFieldElementGraph.getFetches().length ); - // But it should have 1 key-many-to-one fetch for Key (Card is already handled) - assertTrue( cardFieldElementGraph.getIdentifierDescription().hasFetches() ); - final FetchSource cardFieldElementGraphIdAsFetchSource = assertTyping( - FetchSource.class, - cardFieldElementGraph.getIdentifierDescription() - ); - assertEquals( 1, cardFieldElementGraphIdAsFetchSource.getFetches().length ); - assertEquals( 1, cardFieldElementGraphIdAsFetchSource.getBidirectionalEntityReferences().length ); - - BidirectionalEntityReference circularCardFetch = assertTyping( - BidirectionalEntityReference.class, - cardFieldElementGraphIdAsFetchSource.getBidirectionalEntityReferences()[0] - ); - assertSame( circularCardFetch.getTargetEntityReference(), cardReturn ); - - // the fetch above is to the other key-many-to-one for CardField.primaryKey composite: key - EntityFetch keyFetch = assertTyping( - EntityFetch.class, - cardFieldElementGraphIdAsFetchSource.getFetches()[0] - ); - assertEquals( Key.class.getName(), keyFetch.getEntityPersister().getEntityName() ); - } - finally { - sf.close(); - } - } - - @Test - public void testManyToMany() { - Configuration cfg = new Configuration(); - cfg.addResource( "org/hibernate/test/immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml" ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( org.hibernate.test.immutable.entitywithmutablecollection.Contract.class ) ); - } - finally { - sf.close(); - } - - } - - @Test - public void testAnotherBasicCollection() { - Configuration cfg = new Configuration(); - cfg.addAnnotatedClass( Boy.class ); - cfg.addAnnotatedClass( Country.class ); - cfg.addAnnotatedClass( TestCourse.class ); - cfg.addAnnotatedClass( Matrix.class ); - SessionFactoryImplementor sf = (SessionFactoryImplementor) cfg.buildSessionFactory(); - - try { - doCompare( sf, (OuterJoinLoadable) sf.getClassMetadata( Boy.class ) ); - } - finally { - sf.close(); - } - } - - private void doCompare(SessionFactoryImplementor sf, OuterJoinLoadable persister) { - LoadPlanStructureAssertionHelper.INSTANCE.performBasicComparison( sf, persister ); - } -} diff --git a/hibernate-core/src/test/resources/log4j.properties b/hibernate-core/src/test/resources/log4j.properties index 48fedd2a71..d57791943f 100644 --- a/hibernate-core/src/test/resources/log4j.properties +++ b/hibernate-core/src/test/resources/log4j.properties @@ -20,6 +20,7 @@ log4j.rootLogger=info, stdout log4j.logger.org.hibernate.orm.graph=debug log4j.logger.org.hibernate.orm.query.sqm=debug log4j.logger.org.hibernate.orm.query.hql=debug +log4j.logger.org.hibernate.sql.results.graph.DomainResultGraphPrinter=debug log4j.logger.org.hibernate.tool.hbm2ddl=trace log4j.logger.org.hibernate.testing.cache=debug