Skip to content

Commit

Permalink
HHH-17405 Fix failing generic MappedSuperclass comparison test
Browse files Browse the repository at this point in the history
  • Loading branch information
mbladel authored and beikov committed Dec 19, 2023
1 parent da89662 commit 1633b2d
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import org.hibernate.metamodel.model.domain.BasicDomainType;
import org.hibernate.metamodel.model.domain.DomainType;
import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.metamodel.model.domain.SingularPersistentAttribute;
import org.hibernate.metamodel.model.domain.TupleType;
import org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPathSource;
import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
Expand Down Expand Up @@ -74,6 +74,7 @@
import org.hibernate.query.sqm.SetOperator;
import org.hibernate.query.sqm.SortOrder;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.SqmQuerySource;
import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.TrimSpec;
Expand Down Expand Up @@ -1830,19 +1831,25 @@ private static <T> BindableType<T> resolveInferredParameterType(
//noinspection unchecked
return (BindableType<T>) typeInferenceSource;
}

if ( typeInferenceSource.getNodeType() != null ) {
//noinspection unchecked
return (BindableType<T>) typeInferenceSource.getNodeType();
final SqmExpressible<?> nodeType = getNodeType( typeInferenceSource );
if ( nodeType != null ) {
return (BindableType<T>) nodeType;
}
}

if ( value == null ) {
return null;
}
return value == null ? null : (BasicType<T>) typeConfiguration.getBasicTypeForJavaType( value.getClass() );
}

//noinspection unchecked
return (BasicType<T>) typeConfiguration.getBasicTypeForJavaType( value.getClass() );
private static SqmExpressible<?> getNodeType(SqmExpression<?> expression) {
if ( expression instanceof SqmPath<?> ) {
final SqmPathSource<?> pathSource = ( (SqmPath<?>) expression ).getResolvedModel();
return pathSource instanceof SingularPersistentAttribute<?, ?> ?
( (SingularPersistentAttribute<?, ?>) pathSource ).getPathSource() :
pathSource;
}
else {
return expression.getNodeType();
}
}

@Override
Expand Down

0 comments on commit 1633b2d

Please sign in to comment.