/** {@inheritDoc} */ public Parameter<?> getParameter(int position) { if (isJpaPositionalParameter(position)) { return getParameter(Integer.toString(position)); } else { for (Parameter parameter : parameters) { if (parameter.getPosition() != null && position == parameter.getPosition()) { return parameter; } } throw new IllegalArgumentException( "Unable to locate parameter with position [" + position + "]"); } }
protected <X> ParameterRegistration<X> findParameterRegistration(Parameter<X> parameter) { if (ParameterRegistration.class.isInstance(parameter)) { final ParameterRegistration<X> reg = (ParameterRegistration<X>) parameter; // validate the parameter source if (reg.getQuery() != this) { throw new IllegalArgumentException("Passed Parameter was from different Query"); } return reg; } else { if (parameter.getName() != null) { return findParameterRegistration(parameter.getName()); } else if (parameter.getPosition() != null) { return findParameterRegistration(parameter.getPosition()); } } throw new IllegalArgumentException( "Unable to resolve incoming parameter [" + parameter + "] to registration"); }
public TypedQuery<X> setParameter(Parameter<Date> param, Date value, TemporalType temporalType) { if (!parameters.contains(param)) { throw new IllegalArgumentException("Specified parameter was not found in query"); } if (param.getName() != null) { // a named param, for not delegate out. Eventually delegate *into* this method... setParameter(param.getName(), value, temporalType); } else { setParameter(param.getPosition(), value, temporalType); } return this; }