HHH-17116 Small fixes to criteria copy logic for qualified joins
This commit is contained in:
parent
363c06152c
commit
5f88c8d5c0
|
@ -60,8 +60,7 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void copyTo(AbstractSqmPath<T> target, SqmCopyContext context) {
|
protected void copyTo(AbstractSqmPath<T> target, SqmCopyContext context) {
|
||||||
assert lhs == null || lhs.getNavigablePath() == target.getLhs().getNavigablePath()
|
assert navigablePathsMatch( target );
|
||||||
|| getRoot( lhs ).getNodeType() instanceof SqmPolymorphicRootDescriptor;
|
|
||||||
super.copyTo( target, context );
|
super.copyTo( target, context );
|
||||||
if ( reusablePaths != null ) {
|
if ( reusablePaths != null ) {
|
||||||
target.reusablePaths = new HashMap<>( reusablePaths.size() );
|
target.reusablePaths = new HashMap<>( reusablePaths.size() );
|
||||||
|
@ -71,6 +70,13 @@ public abstract class AbstractSqmPath<T> extends AbstractSqmExpression<T> implem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// meant for assertions only
|
||||||
|
private boolean navigablePathsMatch(AbstractSqmPath<T> target) {
|
||||||
|
final SqmPath<?> targetLhs = target.getLhs() != null ? target.getLhs() : target.findRoot();
|
||||||
|
return lhs == null || lhs.getNavigablePath() == targetLhs.getNavigablePath()
|
||||||
|
|| getRoot( lhs ).getNodeType() instanceof SqmPolymorphicRootDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
private SqmPath<?> getRoot(SqmPath<?> lhs) {
|
private SqmPath<?> getRoot(SqmPath<?> lhs) {
|
||||||
return lhs.getLhs() == null ? lhs : getRoot( lhs.getLhs() );
|
return lhs.getLhs() == null ? lhs : getRoot( lhs.getLhs() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,14 +66,13 @@ public class SqmCrossJoin<T> extends AbstractSqmFrom<T, T> implements JpaCrossJo
|
||||||
if ( existing != null ) {
|
if ( existing != null ) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
final SqmRoot<?> rootCopy = getRoot().copy( context );
|
|
||||||
final SqmCrossJoin<T> path = context.registerCopy(
|
final SqmCrossJoin<T> path = context.registerCopy(
|
||||||
this,
|
this,
|
||||||
new SqmCrossJoin<>(
|
new SqmCrossJoin<>(
|
||||||
getNavigablePathCopy( rootCopy ),
|
getNavigablePath(),
|
||||||
getReferencedPathSource(),
|
getReferencedPathSource(),
|
||||||
getExplicitAlias(),
|
getExplicitAlias(),
|
||||||
rootCopy
|
getRoot().copy( context )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
copyTo( path, context );
|
copyTo( path, context );
|
||||||
|
|
|
@ -96,17 +96,16 @@ public class SqmDerivedJoin<T> extends AbstractSqmQualifiedJoin<T, T> implements
|
||||||
if ( existing != null ) {
|
if ( existing != null ) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
final SqmRoot<?> rootCopy = findRoot().copy( context );
|
|
||||||
final SqmDerivedJoin<T> path = context.registerCopy(
|
final SqmDerivedJoin<T> path = context.registerCopy(
|
||||||
this,
|
this,
|
||||||
new SqmDerivedJoin<>(
|
new SqmDerivedJoin<>(
|
||||||
getNavigablePathCopy( rootCopy ),
|
getNavigablePath(),
|
||||||
subQuery,
|
subQuery,
|
||||||
lateral,
|
lateral,
|
||||||
getReferencedPathSource(),
|
getReferencedPathSource(),
|
||||||
getExplicitAlias(),
|
getExplicitAlias(),
|
||||||
getSqmJoinType(),
|
getSqmJoinType(),
|
||||||
rootCopy
|
findRoot().copy( context )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
copyTo( path, context );
|
copyTo( path, context );
|
||||||
|
|
|
@ -70,15 +70,14 @@ public class SqmEntityJoin<T> extends AbstractSqmQualifiedJoin<T, T> implements
|
||||||
if ( existing != null ) {
|
if ( existing != null ) {
|
||||||
return existing;
|
return existing;
|
||||||
}
|
}
|
||||||
final SqmRoot<?> rootCopy = getRoot().copy( context );
|
|
||||||
final SqmEntityJoin<T> path = context.registerCopy(
|
final SqmEntityJoin<T> path = context.registerCopy(
|
||||||
this,
|
this,
|
||||||
new SqmEntityJoin<>(
|
new SqmEntityJoin<>(
|
||||||
getNavigablePathCopy( rootCopy ),
|
getNavigablePath(),
|
||||||
getReferencedPathSource(),
|
getReferencedPathSource(),
|
||||||
getExplicitAlias(),
|
getExplicitAlias(),
|
||||||
getSqmJoinType(),
|
getSqmJoinType(),
|
||||||
rootCopy
|
getRoot().copy( context )
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
copyTo( path, context );
|
copyTo( path, context );
|
||||||
|
|
Loading…
Reference in New Issue