Skip to content

Commit 1633b2d

Browse files
mbelladebeikov
authored andcommitted
HHH-17405 Fix failing generic MappedSuperclass comparison test
1 parent da89662 commit 1633b2d

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

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

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import org.hibernate.metamodel.model.domain.BasicDomainType;
4343
import org.hibernate.metamodel.model.domain.DomainType;
4444
import org.hibernate.metamodel.model.domain.JpaMetamodel;
45-
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
45+
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
4646
import org.hibernate.metamodel.model.domain.TupleType;
4747
import org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPathSource;
4848
import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
@@ -74,6 +74,7 @@
7474
import org.hibernate.query.sqm.SetOperator;
7575
import org.hibernate.query.sqm.SortOrder;
7676
import org.hibernate.query.sqm.SqmExpressible;
77+
import org.hibernate.query.sqm.SqmPathSource;
7778
import org.hibernate.query.sqm.SqmQuerySource;
7879
import org.hibernate.query.sqm.TemporalUnit;
7980
import org.hibernate.query.sqm.TrimSpec;
@@ -1830,19 +1831,25 @@ private static <T> BindableType<T> resolveInferredParameterType(
18301831
//noinspection unchecked
18311832
return (BindableType<T>) typeInferenceSource;
18321833
}
1833-
1834-
if ( typeInferenceSource.getNodeType() != null ) {
1835-
//noinspection unchecked
1836-
return (BindableType<T>) typeInferenceSource.getNodeType();
1834+
final SqmExpressible<?> nodeType = getNodeType( typeInferenceSource );
1835+
if ( nodeType != null ) {
1836+
return (BindableType<T>) nodeType;
18371837
}
18381838
}
18391839

1840-
if ( value == null ) {
1841-
return null;
1842-
}
1840+
return value == null ? null : (BasicType<T>) typeConfiguration.getBasicTypeForJavaType( value.getClass() );
1841+
}
18431842

1844-
//noinspection unchecked
1845-
return (BasicType<T>) typeConfiguration.getBasicTypeForJavaType( value.getClass() );
1843+
private static SqmExpressible<?> getNodeType(SqmExpression<?> expression) {
1844+
if ( expression instanceof SqmPath<?> ) {
1845+
final SqmPathSource<?> pathSource = ( (SqmPath<?>) expression ).getResolvedModel();
1846+
return pathSource instanceof SingularPersistentAttribute<?, ?> ?
1847+
( (SingularPersistentAttribute<?, ?>) pathSource ).getPathSource() :
1848+
pathSource;
1849+
}
1850+
else {
1851+
return expression.getNodeType();
1852+
}
18461853
}
18471854

18481855
@Override

0 commit comments

Comments
 (0)