use of org.hibernate.QueryParameterException in project hibernate-orm by hibernate.
the class QueryParameterBindingsImpl method getBinding.
public QueryParameterBinding getBinding(int position) {
int positionAdjustment = 0;
if (!parameterMetadata.isOrdinalParametersZeroBased()) {
positionAdjustment = -1;
}
QueryParameterBinding binding = null;
if (parameterMetadata != null) {
if (!parameterMetadata.hasPositionalParameters()) {
// no positional parameters, assume jpa named.
binding = locateBinding(Integer.toString(position));
} else {
try {
binding = positionalParameterBindings.get(position + positionAdjustment);
if (binding == null) {
binding = makeBinding(parameterMetadata.getQueryParameter(position));
positionalParameterBindings.put(position + positionAdjustment, binding);
}
} catch (QueryParameterException e) {
// treat this as null binding
}
}
}
if (binding == null) {
throw new IllegalArgumentException("Unknown parameter position: " + position);
}
return binding;
}
use of org.hibernate.QueryParameterException in project hibernate-orm by hibernate.
the class AbstractProducedQuery method getParameterValue.
@Override
public Object getParameterValue(String name) {
getProducer().checkOpen(false);
final QueryParameterBinding binding;
try {
binding = getQueryParameterBindings().getBinding(name);
} catch (QueryParameterException e) {
throw new IllegalArgumentException("Could not resolve parameter by name - " + name, e);
}
LOGGER.debugf("Checking whether named parameter [%s] is bound : %s", name, binding.isBound());
if (!binding.isBound()) {
throw new IllegalStateException("Parameter value not yet bound : " + name);
}
return binding.getBindValue();
}
use of org.hibernate.QueryParameterException in project hibernate-orm by hibernate.
the class AbstractProducedQuery method getParameterValue.
@Override
public Object getParameterValue(int position) {
getProducer().checkOpen(false);
final QueryParameterBinding binding;
try {
binding = getQueryParameterBindings().getBinding(position);
} catch (QueryParameterException e) {
throw new IllegalArgumentException("Could not resolve parameter by position - " + position, e);
}
LOGGER.debugf("Checking whether positional parameter [%s] is bound : %s", (Integer) position, (Boolean) binding.isBound());
if (!binding.isBound()) {
throw new IllegalStateException("Parameter value not yet bound : " + position);
}
return binding.getBindValue();
}
Aggregations