Skip to content

Commit 551951a

Browse files
committed
HHH-19116 Return actual path source for singular attribute joins
This fixes the check for `fk()` function argument type
1 parent aca89a9 commit 551951a

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

hibernate-core/src/main/java/org/hibernate/query/hql/internal/QualifiedJoinPathConsumer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private AttributeJoinDelegate resolveAlias(String identifier, boolean isTerminal
197197
if ( allowReuse ) {
198198
if ( !isTerminal ) {
199199
for ( SqmJoin<?, ?> sqmJoin : lhs.getSqmJoins() ) {
200-
if ( sqmJoin.getAlias() == null && sqmJoin.getReferencedPathSource() == subPathSource ) {
200+
if ( sqmJoin.getAlias() == null && sqmJoin.getModel() == subPathSource ) {
201201
return sqmJoin;
202202
}
203203
}

hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SqmUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public static <T, A> SqmAttributeJoin<T, A> findCompatibleFetchJoin(
427427
SqmPathSource<A> pathSource,
428428
SqmJoinType requestedJoinType) {
429429
for ( final SqmJoin<T, ?> join : sqmFrom.getSqmJoins() ) {
430-
if ( join.getReferencedPathSource() == pathSource ) {
430+
if ( join.getModel() == pathSource ) {
431431
final SqmAttributeJoin<T, ?> attributeJoin = (SqmAttributeJoin<T, ?>) join;
432432
if ( attributeJoin.isFetched() ) {
433433
final SqmJoinType joinType = join.getSqmJoinType();

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/AbstractSqmAttributeJoin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public <X> X accept(SemanticQueryWalker<X> walker) {
122122
@Override
123123
public PersistentAttribute<? super O, ?> getAttribute() {
124124
//noinspection unchecked
125-
return (PersistentAttribute<? super O, ?>) getReferencedPathSource();
125+
return (PersistentAttribute<? super O, ?>) getModel();
126126
}
127127

128128
@Override

hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmSingularJoin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
1515
import org.hibernate.metamodel.model.domain.TreatableDomainType;
1616
import org.hibernate.query.sqm.SemanticQueryWalker;
17+
import org.hibernate.query.sqm.SqmPathSource;
1718
import org.hibernate.spi.NavigablePath;
1819
import org.hibernate.query.hql.spi.SqmCreationProcessingState;
1920
import org.hibernate.query.sqm.NodeBuilder;
@@ -86,6 +87,16 @@ public SqmSingularJoin<O, T> copy(SqmCopyContext context) {
8687
return path;
8788
}
8889

90+
@Override
91+
public SqmPathSource<T> getNodeType() {
92+
return getReferencedPathSource();
93+
}
94+
95+
@Override
96+
public SqmPathSource<T> getReferencedPathSource() {
97+
return getModel().getPathSource();
98+
}
99+
89100
@Override
90101
public SingularPersistentAttribute<O, T> getModel() {
91102
return (SingularPersistentAttribute<O, T>) super.getNodeType();

0 commit comments

Comments
 (0)