HHH-16425 Handle path sources in function return type resolvers
This commit is contained in:
parent
c5c237e70e
commit
0d9ef5444a
|
@ -18,6 +18,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||||
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
|
import org.hibernate.metamodel.mapping.JdbcMappingContainer;
|
||||||
import org.hibernate.query.ReturnableType;
|
import org.hibernate.query.ReturnableType;
|
||||||
import org.hibernate.query.sqm.SqmExpressible;
|
import org.hibernate.query.sqm.SqmExpressible;
|
||||||
|
import org.hibernate.query.sqm.SqmPathSource;
|
||||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||||
import org.hibernate.sql.ast.tree.SqlAstNode;
|
import org.hibernate.sql.ast.tree.SqlAstNode;
|
||||||
import org.hibernate.sql.ast.tree.expression.Expression;
|
import org.hibernate.sql.ast.tree.expression.Expression;
|
||||||
|
@ -103,10 +104,14 @@ public class StandardFunctionReturnTypeResolvers {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ReturnableType<?> resolveFunctionReturnType(ReturnableType<?> impliedType, List<? extends SqmTypedNode<?>> arguments, TypeConfiguration typeConfiguration) {
|
public ReturnableType<?> resolveFunctionReturnType(
|
||||||
for (SqmTypedNode<?> arg: arguments) {
|
ReturnableType<?> impliedType,
|
||||||
if (arg!=null && arg.getNodeType() instanceof ReturnableType ) {
|
List<? extends SqmTypedNode<?>> arguments,
|
||||||
ReturnableType<?> argType = (ReturnableType<?>) arg.getNodeType();
|
TypeConfiguration typeConfiguration) {
|
||||||
|
for ( SqmTypedNode<?> arg : arguments ) {
|
||||||
|
final SqmExpressible<?> argumentNodeType = arg != null ? getArgumentExpressible( arg ) : null;
|
||||||
|
if ( argumentNodeType instanceof ReturnableType ) {
|
||||||
|
ReturnableType<?> argType = (ReturnableType<?>) argumentNodeType;
|
||||||
return isAssignableTo( argType, impliedType ) ? impliedType : argType;
|
return isAssignableTo( argType, impliedType ) ? impliedType : argType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,7 +213,7 @@ public class StandardFunctionReturnTypeResolvers {
|
||||||
List<? extends SqmTypedNode<?>> arguments,
|
List<? extends SqmTypedNode<?>> arguments,
|
||||||
int position) {
|
int position) {
|
||||||
final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 );
|
final SqmTypedNode<?> specifiedArgument = arguments.get( position - 1 );
|
||||||
final SqmExpressible<?> specifiedArgType = specifiedArgument.getNodeType();
|
final SqmExpressible<?> specifiedArgType = getArgumentExpressible( specifiedArgument );
|
||||||
if ( !(specifiedArgType instanceof ReturnableType ) ) {
|
if ( !(specifiedArgType instanceof ReturnableType ) ) {
|
||||||
throw new QueryException(
|
throw new QueryException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -224,6 +229,13 @@ public class StandardFunctionReturnTypeResolvers {
|
||||||
return (ReturnableType<?>) specifiedArgType;
|
return (ReturnableType<?>) specifiedArgType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static SqmExpressible<?> getArgumentExpressible(SqmTypedNode<?> specifiedArgument) {
|
||||||
|
final SqmExpressible<?> specifiedArgType = specifiedArgument.getNodeType();
|
||||||
|
return specifiedArgType instanceof SqmPathSource ?
|
||||||
|
( (SqmPathSource<?>) specifiedArgType ).getSqmPathType() :
|
||||||
|
specifiedArgType;
|
||||||
|
}
|
||||||
|
|
||||||
public static JdbcMapping extractArgumentJdbcMapping(
|
public static JdbcMapping extractArgumentJdbcMapping(
|
||||||
TypeConfiguration typeConfiguration,
|
TypeConfiguration typeConfiguration,
|
||||||
List<? extends SqmTypedNode<?>> arguments,
|
List<? extends SqmTypedNode<?>> arguments,
|
||||||
|
|
Loading…
Reference in New Issue