HHH-15822 Make sure MappedSuperclass can act as type for entity valued paths

This commit is contained in:
Marco Belladelli 2022-12-13 12:52:27 +01:00 committed by Christian Beikov
parent 477f1b1f17
commit 69a5b1faab
2 changed files with 12 additions and 3 deletions

View File

@ -63,10 +63,18 @@ public class SqmEntityValuedSimplePath<T> extends AbstractSqmSimplePath<T> {
}
@Override
public EntityDomainType<T> getNodeType() {
public SqmPathSource<T> getNodeType() {
//noinspection unchecked
return (EntityDomainType<T>) getReferencedPathSource().getSqmPathType();
return (SqmPathSource<T>) 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<T> getNodeType() {
// //noinspection unchecked
// return (EntityDomainType<T>) getReferencedPathSource().getSqmPathType();
// }
@Override
public <S extends T> SqmTreatedSimplePath<T,S> treatAs(Class<S> treatJavaType) throws PathException {

View File

@ -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<T> extends AbstractSqmExpression<T> {
public SqmFkExpression(SqmEntityValuedSimplePath<?> toOnePath, NodeBuilder criteriaBuilder) {
//noinspection unchecked
super( (SqmExpressible<? extends T>) toOnePath.getNodeType().getIdType(), criteriaBuilder );
super( (SqmExpressible<? extends T>) ( (IdentifiableDomainType<?>) toOnePath.getNodeType() ).getIdType(), criteriaBuilder );
this.toOnePath = toOnePath;
}