Fix issue with SqmCorrelatedRootJoin#getNavigablePath(), SqmCorrelatedRootJoin#getReferencedPathSource() and SqmCorrelatedRootJoin#getCorrelationParent() returning null

This commit is contained in:
Andrea Boriero 2021-06-24 18:15:27 +02:00
parent f1d6dc890a
commit 3de89577f8
2 changed files with 9 additions and 15 deletions

View File

@ -19,34 +19,28 @@ import org.hibernate.query.sqm.tree.from.SqmRoot;
*/
public class SqmCorrelatedRootJoin<T> extends SqmRoot<T> implements SqmCorrelation<T, T> {
private final SqmJoin<T, ?> correlationParent;
public SqmCorrelatedRootJoin(
SqmCorrelatedRootJoin(
NavigablePath navigablePath,
SqmPathSource<T> referencedNavigable,
NodeBuilder nodeBuilder,
SqmJoin<T, ?> correlationParent) {
NodeBuilder nodeBuilder) {
super( navigablePath, referencedNavigable, nodeBuilder );
this.correlationParent = correlationParent;
}
public static <X, J extends SqmJoin<X, ?>> SqmCorrelatedRootJoin<X> create(J correlationParent, J correlatedJoin) {
final SqmFrom<?, X> parentPath = (SqmFrom<?, X>) correlationParent.getParentPath();
final SqmCorrelatedRootJoin<X> rootJoin;
if ( parentPath == null ) {
rootJoin = new SqmCorrelatedRootJoin<>(
null,
null,
correlationParent.nodeBuilder(),
correlationParent
rootJoin = new SqmCorrelatedRootJoin(
correlationParent.getNavigablePath(),
correlationParent.getReferencedPathSource(),
correlationParent.nodeBuilder()
);
}
else {
rootJoin = new SqmCorrelatedRootJoin<>(
parentPath.getNavigablePath(),
parentPath.getReferencedPathSource(),
correlationParent.nodeBuilder(),
correlationParent
correlationParent.nodeBuilder()
);
}
rootJoin.addSqmJoin( correlatedJoin );
@ -55,7 +49,7 @@ public class SqmCorrelatedRootJoin<T> extends SqmRoot<T> implements SqmCorrelati
@Override
public SqmRoot<T> getCorrelationParent() {
return null;
return this;
}
@Override

View File

@ -1,4 +1,4 @@
package org.hibernate.test.join;
package org.hibernate.orm.test.join;
import java.util.List;
import javax.persistence.Column;