From 46104cc50e49337a1d0b0f3909dec6186779963d Mon Sep 17 00:00:00 2001 From: Marco Belladelli Date: Tue, 13 Dec 2022 12:52:27 +0100 Subject: [PATCH] HHH-15822 Make sure MappedSuperclass can act as type for entity valued paths --- .../sqm/tree/domain/SqmEntityValuedSimplePath.java | 12 ++++++++++-- .../query/sqm/tree/domain/SqmFkExpression.java | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmEntityValuedSimplePath.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmEntityValuedSimplePath.java index ef699ec16b..09eeac8e08 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmEntityValuedSimplePath.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmEntityValuedSimplePath.java @@ -63,10 +63,18 @@ public class SqmEntityValuedSimplePath extends AbstractSqmSimplePath { } @Override - public EntityDomainType getNodeType() { + public SqmPathSource getNodeType() { //noinspection unchecked - return (EntityDomainType) getReferencedPathSource().getSqmPathType(); + return (SqmPathSource) getReferencedPathSource().getSqmPathType(); } +// We can't expose that the type is a EntityDomainType because it could also be a MappedSuperclass +// Ideally, we would specify the return type to be IdentifiableDomainType, but that does not implement SqmPathSource yet +// and is hence incompatible with the return type of the super class +// @Override +// public EntityDomainType getNodeType() { +// //noinspection unchecked +// return (EntityDomainType) getReferencedPathSource().getSqmPathType(); +// } @Override public SqmTreatedSimplePath treatAs(Class treatJavaType) throws PathException { diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmFkExpression.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmFkExpression.java index d1de261a7f..717dc98076 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmFkExpression.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/tree/domain/SqmFkExpression.java @@ -6,6 +6,7 @@ */ package org.hibernate.query.sqm.tree.domain; +import org.hibernate.metamodel.model.domain.IdentifiableDomainType; import org.hibernate.query.sqm.NodeBuilder; import org.hibernate.query.sqm.SemanticQueryWalker; import org.hibernate.query.sqm.SqmExpressible; @@ -24,7 +25,7 @@ public class SqmFkExpression extends AbstractSqmExpression { public SqmFkExpression(SqmEntityValuedSimplePath toOnePath, NodeBuilder criteriaBuilder) { //noinspection unchecked - super( (SqmExpressible) toOnePath.getNodeType().getIdType(), criteriaBuilder ); + super( (SqmExpressible) ( (IdentifiableDomainType) toOnePath.getNodeType() ).getIdType(), criteriaBuilder ); this.toOnePath = toOnePath; }