/** * Return the value bound to the parameter. * * @param name * name of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(String name) { return _boundParams.get(getParameter(name)); }
/** * Gets the value of all the named parameters. * * If a parameter has been declared but not bound to a value then the value is null and hence is indistinguishable * from the value being actually null. */ public Map<String, Object> getNamedParameters() { lock(); try { Map<String, Object> result = new HashMap<String, Object>(); Set<String> namedKeys = getDeclaredParameterKeys(String.class); for (String name : namedKeys) { Parameter<?> param = getParameter(name); result.put(name, isBound(param) ? getParameterValue(name) : null); } return result; } finally { unlock(); } }
/** * Return the value bound to the parameter. * * @param name * name of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(String name) { return _boundParams.get(getParameter(name)); }
/** * Gets the value of all the named parameters. * * If a parameter has been declared but not bound to a value then the value is null and hence is indistinguishable * from the value being actually null. */ public Map<String, Object> getNamedParameters() { lock(); try { Map<String, Object> result = new HashMap<String, Object>(); Set<String> namedKeys = getDeclaredParameterKeys(String.class); for (String name : namedKeys) { Parameter<?> param = getParameter(name); result.put(name, isBound(param) ? getParameterValue(name) : null); } return result; } finally { unlock(); } }
/** * Return the value bound to the parameter. * * @param name * name of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(String name) { return _boundParams.get(getParameter(name)); }
/** * Gets the array of positional parameter values. The n-th array element represents (n+1)-th positional parameter. * If a parameter has been declared but not bound to a value then the value is null and hence is indistinguishable * from the value being actually null. If the parameter indexing is not contiguous then the unspecified parameters * are considered as null. */ public Object[] getPositionalParameters() { lock(); try { Set<Integer> positionalKeys = getDeclaredParameterKeys(Integer.class); Object[] result = new Object[calculateMaxKey(positionalKeys)]; for (Integer pos : positionalKeys) { Parameter<?> param = getParameter(pos); result[pos.intValue() - 1] = isBound(param) ? getParameterValue(pos) : null; } return result; } finally { unlock(); } }
/** * Return the value bound to the parameter. * * @param name * name of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(String name) { return _boundParams.get(getParameter(name)); }
/** * Gets the array of positional parameter values. The n-th array element represents (n+1)-th positional parameter. * If a parameter has been declared but not bound to a value then the value is null and hence is indistinguishable * from the value being actually null. If the parameter indexing is not contiguous then the unspecified parameters * are considered as null. */ public Object[] getPositionalParameters() { lock(); try { Set<Integer> positionalKeys = getDeclaredParameterKeys(Integer.class); Object[] result = new Object[calculateMaxKey(positionalKeys)]; for (Integer pos : positionalKeys) { Parameter<?> param = getParameter(pos); result[pos.intValue() - 1] = isBound(param) ? getParameterValue(pos) : null; } return result; } finally { unlock(); } }
/** * Get the positional parameter with the given position and type. * * @throws IllegalArgumentException * if the parameter with the specified position does not exist or is not assignable to the type * @throws IllegalStateException * if invoked on a native query unless the same parameter position is bound already. */ public <T> Parameter<T> getParameter(int pos, Class<T> type) { if (_convertPositionalParams == true) { return getParameter("_" + String.valueOf(pos), type); } Parameter<?> param = getParameter(pos); if (param.getParameterType().isAssignableFrom(type)) throw new IllegalArgumentException(param + " does not match the requested type " + type); return (Parameter<T>) param; }
/** * Get the parameter of the given name and type. * * @throws IllegalArgumentException * if the parameter of the specified name does not exist or is not assignable to the type * @throws IllegalStateException * if invoked on a native query */ public <T> Parameter<T> getParameter(String name, Class<T> type) { Parameter<?> param = getParameter(name); if (param.getParameterType().isAssignableFrom(type)) throw new IllegalArgumentException(param + " does not match the requested type " + type); return (Parameter<T>) param; }
/** * Get the parameter of the given name and type. * * @throws IllegalArgumentException * if the parameter of the specified name does not exist or is not assignable to the type * @throws IllegalStateException * if invoked on a native query */ public <T> Parameter<T> getParameter(String name, Class<T> type) { Parameter<?> param = getParameter(name); if (param.getParameterType().isAssignableFrom(type)) throw new IllegalArgumentException(param + " does not match the requested type " + type); return (Parameter<T>) param; }
/** * Return the value bound to the parameter. * * @param pos * position of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(int pos) { Parameter<?> param = getParameter(pos); assertBound(param); return _boundParams.get(param); }
/** * Get the parameter of the given name and type. * * @throws IllegalArgumentException * if the parameter of the specified name does not exist or is not assignable to the type * @throws IllegalStateException * if invoked on a native query */ public <T> Parameter<T> getParameter(String name, Class<T> type) { Parameter<?> param = getParameter(name); if (param.getParameterType().isAssignableFrom(type)) throw new IllegalArgumentException(param + " does not match the requested type " + type); return (Parameter<T>) param; }
/** * Get the parameter of the given name and type. * * @throws IllegalArgumentException * if the parameter of the specified name does not exist or is not assignable to the type * @throws IllegalStateException * if invoked on a native query */ public <T> Parameter<T> getParameter(String name, Class<T> type) { Parameter<?> param = getParameter(name); if (param.getParameterType().isAssignableFrom(type)) throw new IllegalArgumentException(param + " does not match the requested type " + type); return (Parameter<T>) param; }
/** * Return the value bound to the parameter. * * @param pos * position of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(int pos) { Parameter<?> param = getParameter(pos); assertBound(param); return _boundParams.get(param); }
/** * Return the value bound to the parameter. * * @param pos * position of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(int pos) { Parameter<?> param = getParameter(pos); assertBound(param); return _boundParams.get(param); }
/** * Return the value bound to the parameter. * * @param pos * position of the parameter * @return parameter value * * @throws IllegalStateException * if this parameter has not been bound */ public Object getParameterValue(int pos) { Parameter<?> param = getParameter(pos); assertBound(param); return _boundParams.get(param); }
/** * Get the positional parameter with the given position. The parameter may just have been declared and not bound to * a value. * * @param position * specified in the user query. * @return parameter object * @throws IllegalArgumentException * if the parameter with the given position does not exist */ public Parameter<?> getParameter(int pos) { if (_convertPositionalParams == true) { return getParameter("_" + String.valueOf(pos)); } Parameter<?> param = getDeclaredParameters().get(pos); if (param == null) throw new IllegalArgumentException(_loc.get("param-missing-pos", pos, getQueryString(), getDeclaredParameterKeys()).getMessage()); return param; }
/** * Get the positional parameter with the given position. The parameter may just have been declared and not bound to * a value. * * @param position * specified in the user query. * @return parameter object * @throws IllegalArgumentException * if the parameter with the given position does not exist */ public Parameter<?> getParameter(int pos) { if (_convertPositionalParams == true) { return getParameter("_" + String.valueOf(pos)); } Parameter<?> param = getDeclaredParameters().get(pos); if (param == null) throw new IllegalArgumentException(_loc.get("param-missing-pos", pos, getQueryString(), getDeclaredParameterKeys()).getMessage()); return param; }
/** * Sets the parameter of the given name to the given value. */ public OpenJPAQuery<X> setParameter(String name, Object value) { assertOpen(); _em.assertNotCloseInvoked(); lock(); try { // native queries can not have named parameters if (isNative()) { throw new IllegalArgumentException(_loc.get("no-named-params", name, getQueryString()).toString()); } else { bindValue(getParameter(name), value); } return this; } finally { unlock(); } }