From c1c912d034321e78ee16c644d9673e435426f953 Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Mon, 26 Jun 2023 12:45:20 +0200 Subject: [PATCH] HHH-16733 Reuse correct navigable path for correlated and treated copy --- .../sqm/tree/domain/SqmCorrelatedBagJoin.java | 2 +- .../tree/domain/SqmCorrelatedCrossJoin.java | 2 +- .../tree/domain/SqmCorrelatedEntityJoin.java | 2 +- .../tree/domain/SqmCorrelatedListJoin.java | 2 +- .../sqm/tree/domain/SqmCorrelatedMapJoin.java | 2 +- .../sqm/tree/domain/SqmCorrelatedSetJoin.java | 2 +- .../domain/SqmCorrelatedSingularJoin.java | 2 +- .../sqm/tree/domain/SqmTreatedBagJoin.java | 25 ++++++++++++++++++- .../sqm/tree/domain/SqmTreatedCrossJoin.java | 19 +++++++++++++- .../sqm/tree/domain/SqmTreatedEntityJoin.java | 19 +++++++++++++- .../sqm/tree/domain/SqmTreatedListJoin.java | 22 +++++++++++++++- .../sqm/tree/domain/SqmTreatedMapJoin.java | 22 +++++++++++++++- .../tree/domain/SqmTreatedPluralPartJoin.java | 21 +++++++++++++++- .../query/sqm/tree/domain/SqmTreatedRoot.java | 18 ++++++++++++- .../sqm/tree/domain/SqmTreatedSetJoin.java | 22 +++++++++++++++- .../sqm/tree/domain/SqmTreatedSimplePath.java | 18 +++++++++++++ .../tree/domain/SqmTreatedSingularJoin.java | 22 +++++++++++++++- 17 files changed, 206 insertions(+), 16 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedBagJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedBagJoin.java index e2149ebce8..67b02b6370 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedBagJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedBagJoin.java @@ -47,7 +47,7 @@ public class SqmCorrelatedBagJoin extends SqmBagJoin implements SqmC NodeBuilder nodeBuilder, SqmCorrelatedRootJoin correlatedRootJoin, SqmBagJoin correlationParent) { - super( lhs, attribute, alias, sqmJoinType, fetched, nodeBuilder ); + super( lhs, correlationParent.getNavigablePath(), attribute, alias, sqmJoinType, fetched, nodeBuilder ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedCrossJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedCrossJoin.java index 4861bf96ca..c840868f63 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedCrossJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedCrossJoin.java @@ -39,7 +39,7 @@ public class SqmCorrelatedCrossJoin extends SqmCrossJoin implements SqmCor SqmRoot sqmRoot, SqmCorrelatedRootJoin correlatedRootJoin, SqmCrossJoin correlationParent) { - super( joinedEntityDescriptor, alias, sqmRoot ); + super( correlationParent.getNavigablePath(), joinedEntityDescriptor, alias, sqmRoot ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedEntityJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedEntityJoin.java index 0ad2cf1c2e..9f3ecaa820 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedEntityJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedEntityJoin.java @@ -42,7 +42,7 @@ public class SqmCorrelatedEntityJoin extends SqmEntityJoin implements SqmC SqmRoot sqmRoot, SqmCorrelatedRootJoin correlatedRootJoin, SqmEntityJoin correlationParent) { - super( joinedEntityDescriptor, alias, joinType, sqmRoot ); + super( correlationParent.getNavigablePath(), joinedEntityDescriptor, alias, joinType, sqmRoot ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedListJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedListJoin.java index 7e52197da1..75d8f8ab61 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedListJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedListJoin.java @@ -47,7 +47,7 @@ public class SqmCorrelatedListJoin extends SqmListJoin implements Sq NodeBuilder nodeBuilder, SqmCorrelatedRootJoin correlatedRootJoin, SqmListJoin correlationParent) { - super( lhs, attribute, alias, sqmJoinType, fetched, nodeBuilder ); + super( lhs, correlationParent.getNavigablePath(), attribute, alias, sqmJoinType, fetched, nodeBuilder ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedMapJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedMapJoin.java index d984bbeb88..8750f6f460 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedMapJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedMapJoin.java @@ -47,7 +47,7 @@ public class SqmCorrelatedMapJoin extends SqmMapJoin implement NodeBuilder nodeBuilder, SqmCorrelatedRootJoin correlatedRootJoin, SqmMapJoin correlationParent) { - super( lhs, attribute, alias, sqmJoinType, fetched, nodeBuilder ); + super( lhs, correlationParent.getNavigablePath(), attribute, alias, sqmJoinType, fetched, nodeBuilder ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSetJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSetJoin.java index b6e4bd8ed7..cf9358b1c9 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSetJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSetJoin.java @@ -47,7 +47,7 @@ public class SqmCorrelatedSetJoin extends SqmSetJoin implements SqmC NodeBuilder nodeBuilder, SqmCorrelatedRootJoin correlatedRootJoin, SqmSetJoin correlationParent) { - super( lhs, attribute, alias, sqmJoinType, fetched, nodeBuilder ); + super( lhs, correlationParent.getNavigablePath(), attribute, alias, sqmJoinType, fetched, nodeBuilder ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSingularJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSingularJoin.java index 030df61389..0baad24fd7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSingularJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmCorrelatedSingularJoin.java @@ -47,7 +47,7 @@ public class SqmCorrelatedSingularJoin extends SqmSingularJoin imple NodeBuilder nodeBuilder, SqmCorrelatedRootJoin correlatedRootJoin, SqmSingularJoin correlationParent) { - super( lhs, joinedNavigable, alias, joinType, fetched, nodeBuilder ); + super( lhs, correlationParent.getNavigablePath(), joinedNavigable, alias, joinType, fetched, nodeBuilder ); this.correlatedRootJoin = correlatedRootJoin; this.correlationParent = correlationParent; } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedBagJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedBagJoin.java index 1f6127a4b1..3ff7c1e176 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedBagJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedBagJoin.java @@ -12,7 +12,7 @@ import org.hibernate.query.hql.spi.SqmCreationProcessingState; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -42,6 +42,28 @@ public class SqmTreatedBagJoin extends SqmBagJoin impleme this.wrappedPath = wrappedPath; } + private SqmTreatedBagJoin( + NavigablePath navigablePath, + SqmBagJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + wrappedPath.getLhs(), + wrappedPath.getNavigablePath().treatAs( + treatTarget.getHibernateEntityName(), + alias + ), + (BagPersistentAttribute) wrappedPath.getAttribute(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.isFetched(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedBagJoin copy(SqmCopyContext context) { final SqmTreatedBagJoin existing = context.getCopy( this ); @@ -51,6 +73,7 @@ public class SqmTreatedBagJoin extends SqmBagJoin impleme final SqmTreatedBagJoin path = context.registerCopy( this, new SqmTreatedBagJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedCrossJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedCrossJoin.java index 2e3beb537f..f7dfb9a9aa 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedCrossJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedCrossJoin.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmCrossJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -34,6 +34,22 @@ public class SqmTreatedCrossJoin extends SqmCrossJoin impleme this.treatTarget = treatTarget; } + private SqmTreatedCrossJoin( + NavigablePath navigablePath, + SqmCrossJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + navigablePath, + (EntityDomainType) wrappedPath.getReferencedPathSource().getSqmPathType(), + alias, + wrappedPath.getRoot() + ); + this.wrappedPath = wrappedPath; + this.treatTarget = treatTarget; + } + @Override public SqmTreatedCrossJoin copy(SqmCopyContext context) { final SqmTreatedCrossJoin existing = context.getCopy( this ); @@ -43,6 +59,7 @@ public class SqmTreatedCrossJoin extends SqmCrossJoin impleme final SqmTreatedCrossJoin path = context.registerCopy( this, new SqmTreatedCrossJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedEntityJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedEntityJoin.java index f8c5710c65..0b8d145dae 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedEntityJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedEntityJoin.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmEntityJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -37,6 +37,22 @@ public class SqmTreatedEntityJoin extends SqmEntityJoin imple this.treatTarget = treatTarget; } + private SqmTreatedEntityJoin( + NavigablePath navigablePath, + SqmEntityJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + super( + navigablePath, + treatTarget, + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.getRoot() + ); + this.wrappedPath = wrappedPath; + this.treatTarget = treatTarget; + } + @Override public SqmTreatedEntityJoin copy(SqmCopyContext context) { final SqmTreatedEntityJoin existing = context.getCopy( this ); @@ -46,6 +62,7 @@ public class SqmTreatedEntityJoin extends SqmEntityJoin imple final SqmTreatedEntityJoin path = context.registerCopy( this, new SqmTreatedEntityJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedListJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedListJoin.java index 74c49ddbb7..e3f5c8f7ce 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedListJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedListJoin.java @@ -14,7 +14,7 @@ import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.expression.SqmExpression; import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -44,6 +44,25 @@ public class SqmTreatedListJoin extends SqmListJoin imple this.wrappedPath = wrappedPath; } + private SqmTreatedListJoin( + NavigablePath navigablePath, + SqmListJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + wrappedPath.getLhs(), + navigablePath, + (ListPersistentAttribute) wrappedPath.getAttribute(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.isFetched(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedListJoin copy(SqmCopyContext context) { final SqmTreatedListJoin existing = context.getCopy( this ); @@ -53,6 +72,7 @@ public class SqmTreatedListJoin extends SqmListJoin imple final SqmTreatedListJoin path = context.registerCopy( this, new SqmTreatedListJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedMapJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedMapJoin.java index ba3f42701a..df076cc0b3 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedMapJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedMapJoin.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.hql.spi.SqmCreationProcessingState; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -40,6 +40,25 @@ public class SqmTreatedMapJoin extends SqmMapJoin this.wrappedPath = wrappedPath; } + private SqmTreatedMapJoin( + NavigablePath navigablePath, + SqmMapJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + wrappedPath.getLhs(), + navigablePath, + ( (SqmMapJoin) wrappedPath ).getModel(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.isFetched(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedMapJoin copy(SqmCopyContext context) { final SqmTreatedMapJoin existing = context.getCopy( this ); @@ -49,6 +68,7 @@ public class SqmTreatedMapJoin extends SqmMapJoin final SqmTreatedMapJoin path = context.registerCopy( this, new SqmTreatedMapJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedPluralPartJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedPluralPartJoin.java index 100ff4c195..281aa36756 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedPluralPartJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedPluralPartJoin.java @@ -10,7 +10,7 @@ import org.hibernate.metamodel.model.domain.EntityDomainType; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmFrom; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -39,6 +39,24 @@ public class SqmTreatedPluralPartJoin extends SqmPluralPartJoi this.wrappedPath = wrappedPath; } + private SqmTreatedPluralPartJoin( + NavigablePath navigablePath, + SqmPluralPartJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + (SqmFrom) wrappedPath.getLhs(), + navigablePath, + (SqmPathSource) wrappedPath.getReferencedPathSource(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedPluralPartJoin copy(SqmCopyContext context) { final SqmTreatedPluralPartJoin existing = context.getCopy( this ); @@ -48,6 +66,7 @@ public class SqmTreatedPluralPartJoin extends SqmPluralPartJoi final SqmTreatedPluralPartJoin path = context.registerCopy( this, new SqmTreatedPluralPartJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedRoot.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedRoot.java index 318aceae3f..e653333645 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedRoot.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedRoot.java @@ -11,8 +11,8 @@ import org.hibernate.query.hql.spi.SqmCreationState; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; -import org.hibernate.query.sqm.tree.from.SqmJoin; import org.hibernate.query.sqm.tree.from.SqmRoot; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -37,6 +37,21 @@ public class SqmTreatedRoot extends SqmRoot implements SqmTre this.treatTarget = treatTarget; } + @SuppressWarnings({ "unchecked", "rawtypes" }) + private SqmTreatedRoot( + NavigablePath navigablePath, + SqmRoot wrappedPath, + EntityDomainType treatTarget) { + super( + navigablePath, + (EntityDomainType) wrappedPath.getReferencedPathSource(), + null, + wrappedPath.nodeBuilder() + ); + this.wrappedPath = wrappedPath; + this.treatTarget = treatTarget; + } + @Override public SqmRoot copy(SqmCopyContext context) { final SqmTreatedRoot existing = context.getCopy( this ); @@ -46,6 +61,7 @@ public class SqmTreatedRoot extends SqmRoot implements SqmTre final SqmTreatedRoot path = context.registerCopy( this, new SqmTreatedRoot<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget ) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSetJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSetJoin.java index 51cad5bf11..813d50d100 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSetJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSetJoin.java @@ -12,7 +12,7 @@ import org.hibernate.query.hql.spi.SqmCreationProcessingState; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -42,6 +42,25 @@ public class SqmTreatedSetJoin extends SqmSetJoin impleme this.wrappedPath = wrappedPath; } + private SqmTreatedSetJoin( + NavigablePath navigablePath, + SqmSetJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + wrappedPath.getLhs(), + navigablePath, + (SetPersistentAttribute) wrappedPath.getAttribute(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.isFetched(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedSetJoin copy(SqmCopyContext context) { final SqmTreatedSetJoin existing = context.getCopy( this ); @@ -51,6 +70,7 @@ public class SqmTreatedSetJoin extends SqmSetJoin impleme final SqmTreatedSetJoin path = context.registerCopy( this, new SqmTreatedSetJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSimplePath.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSimplePath.java index ce859c826e..bdbf719277 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSimplePath.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSimplePath.java @@ -12,6 +12,7 @@ import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -57,6 +58,22 @@ public class SqmTreatedSimplePath this.wrappedPath = wrappedPath; } + private SqmTreatedSimplePath( + NavigablePath navigablePath, + SqmPath wrappedPath, + EntityDomainType treatTarget, + NodeBuilder nodeBuilder) { + //noinspection unchecked + super( + navigablePath, + (SqmPathSource) wrappedPath.getReferencedPathSource(), + wrappedPath.getLhs(), + nodeBuilder + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedSimplePath copy(SqmCopyContext context) { final SqmTreatedSimplePath existing = context.getCopy( this ); @@ -67,6 +84,7 @@ public class SqmTreatedSimplePath final SqmTreatedSimplePath path = context.registerCopy( this, new SqmTreatedSimplePath<>( + getNavigablePath(), wrappedPath.copy( context ), getTreatTarget(), nodeBuilder() diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSingularJoin.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSingularJoin.java index a7abbfe150..c820b78c23 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSingularJoin.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmTreatedSingularJoin.java @@ -12,7 +12,7 @@ import org.hibernate.query.hql.spi.SqmCreationProcessingState; import org.hibernate.query.sqm.SqmPathSource; import org.hibernate.query.sqm.tree.SqmCopyContext; import org.hibernate.query.sqm.tree.from.SqmAttributeJoin; -import org.hibernate.query.sqm.tree.from.SqmJoin; +import org.hibernate.spi.NavigablePath; /** * @author Steve Ebersole @@ -42,6 +42,25 @@ public class SqmTreatedSingularJoin extends SqmSingularJoin wrappedPath, + EntityDomainType treatTarget, + String alias) { + //noinspection unchecked + super( + wrappedPath.getLhs(), + navigablePath, + (SingularPersistentAttribute) wrappedPath.getAttribute(), + alias, + wrappedPath.getSqmJoinType(), + wrappedPath.isFetched(), + wrappedPath.nodeBuilder() + ); + this.treatTarget = treatTarget; + this.wrappedPath = wrappedPath; + } + @Override public SqmTreatedSingularJoin copy(SqmCopyContext context) { final SqmTreatedSingularJoin existing = context.getCopy( this ); @@ -51,6 +70,7 @@ public class SqmTreatedSingularJoin extends SqmSingularJoin path = context.registerCopy( this, new SqmTreatedSingularJoin<>( + getNavigablePath(), wrappedPath.copy( context ), treatTarget, getExplicitAlias()