HHH-17405 Fix failing generic MappedSuperclass comparison test

This commit is contained in:
Marco Belladelli 2023-12-05 17:38:00 +01:00 committed by Christian Beikov
parent da89662241
commit 1633b2d2c7
1 changed files with 17 additions and 10 deletions

View File

@ -42,7 +42,7 @@ import org.hibernate.internal.util.collections.CollectionHelper;
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;
@ -74,6 +74,7 @@ import org.hibernate.query.sqm.NullPrecedence;
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;
@ -1830,19 +1831,25 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
//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