Search in sources :

Example 6 with QueryParameterBinding

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;
}
Also used : QueryParameterBinding(org.hibernate.query.spi.QueryParameterBinding) QueryParameterListBinding(org.hibernate.query.spi.QueryParameterListBinding)

Example 7 with QueryParameterBinding

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;
}
Also used : QueryParameterBinding(org.hibernate.query.spi.QueryParameterBinding)

Example 8 with QueryParameterBinding

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() {
    Map<String, TypedValue> collectedBindings = new HashMap<>();
    for (Map.Entry<QueryParameter, QueryParameterBinding> entry : parameterBindingMap.entrySet()) {
        if (entry.getKey().getName() == null) {
            continue;
        }
        Type bindType = entry.getValue().getBindType();
        if (bindType == null) {
            log.debugf("Binding for named-parameter [%s] did not define type", entry.getKey().getName());
            bindType = SerializableType.INSTANCE;
        }
        collectedBindings.put(entry.getKey().getName(), new TypedValue(bindType, entry.getValue().getBindValue()));
    }
    return collectedBindings;
}
Also used : QueryParameter(org.hibernate.query.QueryParameter) SerializableType(org.hibernate.type.SerializableType) Type(org.hibernate.type.Type) QueryParameterBinding(org.hibernate.query.spi.QueryParameterBinding) HashMap(java.util.HashMap) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) TypedValue(org.hibernate.engine.spi.TypedValue)

Aggregations

QueryParameterBinding (org.hibernate.query.spi.QueryParameterBinding)8 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TreeMap (java.util.TreeMap)4 QueryParameter (org.hibernate.query.QueryParameter)3 SerializableType (org.hibernate.type.SerializableType)3 Type (org.hibernate.type.Type)3 QueryParameterListBinding (org.hibernate.query.spi.QueryParameterListBinding)2 Collection (java.util.Collection)1 QueryException (org.hibernate.QueryException)1 QueryParameterException (org.hibernate.QueryParameterException)1 Dialect (org.hibernate.dialect.Dialect)1 NamedParameterDescriptor (org.hibernate.engine.query.spi.NamedParameterDescriptor)1 TypedValue (org.hibernate.engine.spi.TypedValue)1