diff --git a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java index ce96b0f818..ab76ad1501 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java +++ b/hibernate-core/src/main/java/org/hibernate/query/spi/QueryEngine.java @@ -40,7 +40,7 @@ public class QueryEngine { SessionFactoryImplementor sessionFactory, NamedQueryRepository namedQueryRepository) { return new QueryEngine( - sessionFactory.getDomainModel(), + sessionFactory.getMetamodel(), sessionFactory.getServiceRegistry(), sessionFactory.getSessionFactoryOptions(), sessionFactory, diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/consume/spi/QuerySplitter.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/consume/spi/QuerySplitter.java index 80c728ee9c..0c0c317bfb 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/consume/spi/QuerySplitter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/consume/spi/QuerySplitter.java @@ -12,7 +12,8 @@ import java.util.Map; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.collections.Stack; -import org.hibernate.metamodel.model.mapping.EntityTypeDescriptor; +import org.hibernate.metamodel.model.domain.EntityDomainType; +import org.hibernate.metamodel.model.domain.SingularPersistentAttribute; import org.hibernate.query.NavigablePath; import org.hibernate.query.sqm.produce.SqmCreationProcessingState; import org.hibernate.query.sqm.produce.SqmPathRegistry; @@ -100,7 +101,7 @@ public class QuerySplitter { final SqmSelectStatement[] expanded = new SqmSelectStatement[ unmappedPolymorphicDescriptor.getImplementors().size() ]; int i = -1; - for ( EntityTypeDescriptor mappedDescriptor : unmappedPolymorphicDescriptor.getImplementors() ) { + for ( EntityDomainType mappedDescriptor : unmappedPolymorphicDescriptor.getImplementors() ) { i++; final UnmappedPolymorphismReplacer replacer = new UnmappedPolymorphismReplacer( unmappedPolymorphicReference, @@ -116,14 +117,14 @@ public class QuerySplitter { @SuppressWarnings("unchecked") private static class UnmappedPolymorphismReplacer extends BaseSemanticQueryWalker implements SqmCreationState { private final SqmRoot unmappedPolymorphicFromElement; - private final EntityTypeDescriptor mappedDescriptor; + private final EntityDomainType mappedDescriptor; private Map sqmPathCopyMap = new HashMap<>(); private Map sqmFromCopyMap = new HashMap<>(); private UnmappedPolymorphismReplacer( SqmRoot unmappedPolymorphicFromElement, - EntityTypeDescriptor mappedDescriptor, + EntityDomainType mappedDescriptor, SessionFactoryImplementor sessionFactory) { super( sessionFactory.getServiceRegistry() ); this.unmappedPolymorphicFromElement = unmappedPolymorphicFromElement; @@ -231,7 +232,7 @@ public class QuerySplitter { } else { copy = new SqmRoot( - sqmRoot.getReferencedPathSource().getEntityDescriptor(), + sqmRoot.getReferencedPathSource(), sqmRoot.getExplicitAlias(), sqmRoot.nodeBuilder() ); @@ -249,7 +250,7 @@ public class QuerySplitter { join.getNavigablePath(), navigablePath -> { final SqmCrossJoin copy = new SqmCrossJoin( - join.getReferencedPathSource().getEntityDescriptor(), + join.getReferencedPathSource(), join.getExplicitAlias(), (SqmRoot) sqmFromCopyMap.get( join.findRoot() ) ); @@ -266,7 +267,8 @@ public class QuerySplitter { join.getNavigablePath(), navigablePath -> { final SqmEntityJoin copy = new SqmEntityJoin( - join.getReferencedPathSource().getEntityDescriptor(), join.getExplicitAlias(), + join.getReferencedPathSource(), + join.getExplicitAlias(), join.getSqmJoinType(), (SqmRoot) sqmFromCopyMap.get( join.findRoot() ) ); @@ -282,16 +284,17 @@ public class QuerySplitter { return (SqmAttributeJoin) getProcessingStateStack().getCurrent().getPathRegistry().resolvePath( join.getNavigablePath(), navigablePath -> { - final SqmAttributeJoin copy = new SqmSingularJoin( - getProcessingStateStack().getCurrent() - .getPathRegistry() - .findFromByPath( join.getLhs().getNavigablePath() ), - join.getReferencedPathSource(), - join.getExplicitAlias(), - join.getSqmJoinType(), - join.isFetched(), - join.nodeBuilder() - ); + SqmAttributeJoin copy = join.makeCopy(getProcessingStateStack().getCurrent()); +// final SqmAttributeJoin copy = new SqmSingularJoin( +// getProcessingStateStack().getCurrent() +// .getPathRegistry() +// .findFromByPath( join.getLhs().getNavigablePath() ), +// (SingularPersistentAttribute) join.getReferencedPathSource(), +// join.getExplicitAlias(), +// join.getSqmJoinType(), +// join.isFetched(), +// join.nodeBuilder() +// ); sqmFromCopyMap.put( join, copy ); sqmPathCopyMap.put( join.getNavigablePath(), copy ); return copy; diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmAttributeJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmAttributeJoin.java index abedb4844e..23407c55f5 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmAttributeJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/from/SqmAttributeJoin.java @@ -10,6 +10,7 @@ import org.hibernate.HibernateException; import org.hibernate.query.criteria.JpaFetch; import org.hibernate.query.criteria.JpaJoin; import org.hibernate.query.sqm.SqmPathSource; +import org.hibernate.query.sqm.produce.SqmCreationProcessingState; import org.hibernate.query.sqm.tree.predicate.SqmPredicate; import org.hibernate.type.descriptor.java.JavaTypeDescriptor; @@ -35,6 +36,8 @@ public interface SqmAttributeJoin extends SqmQualifiedJoin, JpaFetch