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