Skip to content

Commit

Permalink
HHH-15822 Make sure MappedSuperclass can act as type for entity value…
Browse files Browse the repository at this point in the history
…d paths
  • Loading branch information
mbladel authored and beikov committed Jan 27, 2023
1 parent 477f1b1 commit 69a5b1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,18 @@ public <X> X accept(SemanticQueryWalker<X> walker) {
}

@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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down

0 comments on commit 69a5b1f

Please sign in to comment.