HHH-15542 Cannot invoke 'org.hibernate.query.BindableType.getBindableJavaType()' because 'parameterType' is null

This commit is contained in:
Andrea Boriero 2022-09-26 16:33:12 +02:00 committed by Andrea Boriero
parent da1b1d6b75
commit cfc9b9c679
2 changed files with 18 additions and 13 deletions

View File

@ -462,23 +462,13 @@ public class ProcedureCallImpl<R>
public <T> ProcedureParameter<T> registerParameter(int position, Class<T> javaType, ParameterMode mode) { public <T> ProcedureParameter<T> registerParameter(int position, Class<T> javaType, ParameterMode mode) {
final BindableType<T> parameterType = getSessionFactory().resolveParameterBindType( javaType ); final BindableType<T> parameterType = getSessionFactory().resolveParameterBindType( javaType );
final Class<T> expressibleJavaType;
if ( parameterType == null ) {
expressibleJavaType = null;
}
else {
final SqmExpressible<T> sqmExpressible = parameterType.resolveExpressible( getSessionFactory() );
assert sqmExpressible != null;
expressibleJavaType = sqmExpressible.getExpressibleJavaType().getJavaTypeClass();
}
final ProcedureParameterImpl<T> procedureParameter = new ProcedureParameterImpl<>( final ProcedureParameterImpl<T> procedureParameter = new ProcedureParameterImpl<>(
position, position,
mode, mode,
expressibleJavaType, getExpressibleJavaType( parameterType ),
parameterType parameterType
); );
registerParameter( procedureParameter ); registerParameter( procedureParameter );
return procedureParameter; return procedureParameter;
@ -518,7 +508,7 @@ public class ProcedureCallImpl<R>
final ProcedureParameterImpl<T> parameter = new ProcedureParameterImpl<>( final ProcedureParameterImpl<T> parameter = new ProcedureParameterImpl<>(
name, name,
mode, mode,
parameterType.getBindableJavaType(), getExpressibleJavaType( parameterType ),
parameterType parameterType
); );
@ -527,6 +517,18 @@ public class ProcedureCallImpl<R>
return parameter; return parameter;
} }
private <T> Class<T> getExpressibleJavaType(BindableType<T> parameterType) {
if ( parameterType == null ) {
return null;
}
else {
final SqmExpressible<T> sqmExpressible = parameterType.resolveExpressible( getSessionFactory() );
assert sqmExpressible != null;
return sqmExpressible.getExpressibleJavaType().getJavaTypeClass();
}
}
@Override @Override
public <T> ProcedureParameterImplementor<T> registerParameter( public <T> ProcedureParameterImplementor<T> registerParameter(
String name, String name,

View File

@ -187,6 +187,9 @@ public class ProcedureParameterImpl<T> extends AbstractQueryParameter<T> impleme
}; };
} }
} }
else if ( typeToUse == null ) {
throw new IllegalArgumentException( "Cannot determine the bindable type for procedure parameter: " + name );
}
else { else {
throw new NotYetImplementedFor6Exception( getClass() ); throw new NotYetImplementedFor6Exception( getClass() );
} }