use of org.hibernate.query.spi.QueryParameterBinding in project hibernate-orm by hibernate.
the class ProcedureCallImpl method setParameter.
@Override
@SuppressWarnings("unchecked")
public ProcedureCallImplementor<R> setParameter(String name, Object value, Type type) {
final QueryParameterBinding binding = paramBindings.getBinding(getParameterMetadata().getQueryParameter(name));
binding.setBindValue(value, type);
return this;
}
use of org.hibernate.query.spi.QueryParameterBinding in project hibernate-orm by hibernate.
the class QueryParameterBindingsImpl method isBound.
public boolean isBound(QueryParameter parameter) {
final QueryParameterBinding binding = locateBinding(parameter);
if (binding != null) {
return binding.getBindValue() != null;
}
final QueryParameterListBinding listBinding = locateQueryParameterListBinding(parameter);
if (listBinding != null) {
return listBinding.getBindValues() != null;
}
return false;
}
use of org.hibernate.query.spi.QueryParameterBinding in project hibernate-orm by hibernate.
the class QueryParameterBindingsImpl method transformQueryParameterBindingToQueryParameterListBinding.
/**
* @deprecated (since 5.2) expected changes to "collection-valued parameter binding" in 6.0
*/
@Deprecated
private <T> QueryParameterListBinding<T> transformQueryParameterBindingToQueryParameterListBinding(QueryParameter<T> queryParameter) {
log.debugf("Converting QueryParameterBinding to QueryParameterListBinding for given QueryParameter : %s", queryParameter);
final QueryParameterBinding binding = getAndRemoveBinding(queryParameter);
if (binding == null) {
throw new IllegalArgumentException("Could not locate QueryParameterBinding for given QueryParameter : " + queryParameter + "; parameter list must be defined using named parameter");
}
final QueryParameterListBinding<T> convertedBinding = new QueryParameterListBindingImpl<>(binding.getBindType(), shouldValidateBindingValue());
parameterListBindingMap.put(queryParameter, convertedBinding);
return convertedBinding;
}
use of org.hibernate.query.spi.QueryParameterBinding 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();
}
use of org.hibernate.query.spi.QueryParameterBinding in project hibernate-orm by hibernate.
the class QueryParameterBindingsImpl method collectNamedParameterBindings.
/**
* @deprecated (since 5.2) expect a different approach to org.hibernate.engine.spi.QueryParameters in 6.0
*/
@Deprecated
public Map<String, TypedValue> collectNamedParameterBindings() {
final Map<String, TypedValue> collectedBindings = new HashMap<>();
for (Map.Entry<QueryParameter, QueryParameterBinding> entry : parameterBindingMap.entrySet()) {
final String key;
if (entry.getKey().getPosition() != null) {
key = Integer.toString(entry.getKey().getPosition());
} else {
key = entry.getKey().getName();
}
Type bindType = entry.getValue().getBindType();
if (bindType == null) {
log.debugf("Binding for parameter [%s] did not define type", key);
bindType = SerializableType.INSTANCE;
}
collectedBindings.put(key, new TypedValue(bindType, entry.getValue().getBindValue()));
}
return collectedBindings;
}
Aggregations