You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spring Data JPA creates a JPA-compliant Parameter instance and supplies it through Query.setParameter(Parameter<T> param, T value). This ends up inside EJBQueryImpl, where it breaks.
@Overridepublic <T> TypedQuerysetParameter(Parameter<T> param, Tvalue) {
if (param == null) {
thrownewIllegalArgumentException(ExceptionLocalization.buildMessage("NULL_PARAMETER_PASSED_TO_SET_PARAMETER"));
}
//bug 402686: type validationStringposition = getParameterId(param); // <----- this is where it failsParameterExpressionImplparameter = (ParameterExpressionImpl) this.getInternalParameters().get(position);
if (parameter == null ) {
thrownewIllegalArgumentException(ExceptionLocalization.buildMessage("NO_PARAMETER_WITH_NAME", newObject[] { param.toString(), this.databaseQuery }));
}
if (!parameter.getParameterType().equals(param.getParameterType())) {
thrownewIllegalArgumentException(ExceptionLocalization.buildMessage("INCORRECT_PARAMETER_TYPE", newObject[] { position, param.getParameterType() }));
}
returnthis.setParameter(position, value);
}
When it invokes getParameterId against the Parameter<T>, EL is assuming that this is an internal type instead of a JPA type, and attempts a cast operation, which in our situation fails.
publicstaticStringgetParameterId(Parameterparam){
Integerid= param.getPosition();
if (id == null ){
returnString.valueOf(((ParameterExpressionImpl)param).getInternalName()); // <--- perhaps param.getName() instead?
}
returnString.valueOf(id);
}
Because we are supplying a name-based parameter, a JPA Parameter.getName() operation, which would have worked, is traded for a downcast and then an invocation for an internal name operation.
Perhaps consider FIRST checking if there is a param.getName() result and deferring to that?
You're clearly using the getPosition() call, so why not stick to the interface operations?
The text was updated successfully, but these errors were encountered:
Spring Data JPA creates a JPA-compliant
Parameter
instance and supplies it throughQuery.setParameter(Parameter<T> param, T value)
. This ends up insideEJBQueryImpl
, where it breaks.When it invokes
getParameterId
against theParameter<T>
, EL is assuming that this is an internal type instead of a JPA type, and attempts a cast operation, which in our situation fails.Because we are supplying a name-based parameter, a JPA
Parameter.getName()
operation, which would have worked, is traded for a downcast and then an invocation for an internal name operation.Perhaps consider FIRST checking if there is a
param.getName()
result and deferring to that?You're clearly using the
getPosition()
call, so why not stick to the interface operations?The text was updated successfully, but these errors were encountered: