@Override public Value toValue(ExpressionFactory factory, CriteriaQueryImpl<?> q) { Class<?> clzz = getJavaType(); Object paramKey = _name == null ? _index : _name; boolean isCollectionValued = Collection.class.isAssignableFrom(clzz); org.apache.openjpa.kernel.exps.Parameter param = isCollectionValued ? factory.newCollectionValuedParameter(paramKey, clzz) : factory.newParameter(paramKey, clzz); param.setIndex(_index); return param; }
/** * Marks the positions and keys of user parameters. * * @param list even elements are numbers representing the position of a * user parameter in the _param list. Odd elements are the user parameter * key. A user parameter key may appear more than once. */ void setUserParameterPositions(List list) { _userParamPositions = new HashMap<Object, Integer[]>(); List<Integer> positions = new ArrayList<Integer>(); for (int i = 1; list != null && i < list.size(); i += 2) { Object key = ((Parameter)list.get(i)).getParameterKey(); positions.clear(); for (int j = 1; j < list.size(); j += 2) { Object other = ((Parameter)list.get(j)).getParameterKey(); if (key.equals(other)) positions.add((Integer)list.get(j-1)); } _userParamPositions.put(key, positions.toArray(new Integer[positions.size()])); } }
@Override public void enter(Value val) { log.debug("in enter with value {}", val); // it's a variable add it to the field if (val instanceof CandidatePath) { field = ((CandidatePath) val).last(); log.debug("field name {} and {}", field.getName(), field); return; } if (val instanceof Literal) { value = ((Literal) val).getValue(); return; } if (val instanceof Parameter) { log.debug("reset with value {}", val); value = ((Parameter) val).getValue(params); return; } if(val instanceof Null){ value = null; return; } }
param.setMetaData(meta); param.setIndex(index);
protected void setImplicitTypes(Value val1, Value val2, Class expected) { super.setImplicitTypes(val1, val2, expected); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; Class type = path.isXPath() ? path.getType() : fmd.getType(); if (type == null) return; String paramName = param.getParameterName(); if (paramName == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramName)) parameterTypes.put(paramName, type); }
? factory.newCollectionValuedParameter(paramKey, TYPE_OBJECT) : factory.newParameter(paramKey, TYPE_OBJECT); param.setMetaData(meta); param.setIndex(index);
? factory.newCollectionValuedParameter(paramKey, TYPE_OBJECT) : factory.newParameter(paramKey, TYPE_OBJECT); param.setMetaData(meta); param.setIndex(index);
/** * Marks the positions and keys of user parameters. * * @param list even elements are numbers representing the position of a * user parameter in the _param list. Odd elements are the user parameter * key. A user parameter key may appear more than once. */ void setUserParameterPositions(List list) { _userParamPositions = new HashMap<Object, Integer[]>(); List<Integer> positions = new ArrayList<Integer>(); for (int i = 1; list != null && i < list.size(); i += 2) { Object key = ((Parameter)list.get(i)).getParameterKey(); positions.clear(); for (int j = 1; j < list.size(); j += 2) { Object other = ((Parameter)list.get(j)).getParameterKey(); if (key.equals(other)) positions.add((Integer)list.get(j-1)); } _userParamPositions.put(key, positions.toArray(new Integer[positions.size()])); } }
@Override public Value toValue(ExpressionFactory factory, CriteriaQueryImpl<?> q) { Class<?> clzz = getJavaType(); Object paramKey = _name == null ? _index : _name; boolean isCollectionValued = Collection.class.isAssignableFrom(clzz); org.apache.openjpa.kernel.exps.Parameter param = isCollectionValued ? factory.newCollectionValuedParameter(paramKey, clzz) : factory.newParameter(paramKey, clzz); param.setIndex(_index); return param; }
? factory.newCollectionValuedParameter(paramKey, TYPE_OBJECT) : factory.newParameter(paramKey, TYPE_OBJECT); param.setMetaData(meta); param.setIndex(index);
/** * Marks the positions and keys of user parameters. * * @param list even elements are numbers representing the position of a * user parameter in the _param list. Odd elements are the user parameter * key. A user parameter key may appear more than once. */ void setUserParameterPositions(List list) { _userParamPositions = new HashMap<Object, Integer[]>(); List<Integer> positions = new ArrayList<Integer>(); for (int i = 1; list != null && i < list.size(); i += 2) { Object key = ((Parameter)list.get(i)).getParameterKey(); positions.clear(); for (int j = 1; j < list.size(); j += 2) { Object other = ((Parameter)list.get(j)).getParameterKey(); if (key.equals(other)) positions.add((Integer)list.get(j-1)); } _userParamPositions.put(key, positions.toArray(new Integer[positions.size()])); } }
@Override public Value toValue(ExpressionFactory factory, CriteriaQueryImpl<?> q) { Class<?> clzz = getJavaType(); Object paramKey = _name == null ? _index : _name; boolean isCollectionValued = Collection.class.isAssignableFrom(clzz); org.apache.openjpa.kernel.exps.Parameter param = isCollectionValued ? factory.newCollectionValuedParameter(paramKey, clzz) : factory.newParameter(paramKey, clzz); param.setIndex(_index); return param; }
? factory.newCollectionValuedParameter(paramKey, TYPE_OBJECT) : factory.newParameter(paramKey, TYPE_OBJECT); param.setMetaData(meta); param.setIndex(index);
/** * Marks the positions and keys of user parameters. * * @param list even elements are numbers representing the position of a * user parameter in the _param list. Odd elements are the user parameter * key. A user parameter key may appear more than once. */ void setUserParameterPositions(List list) { _userParamPositions = new HashMap<Object, Integer[]>(); List<Integer> positions = new ArrayList<Integer>(); for (int i = 1; list != null && i < list.size(); i += 2) { Object key = ((Parameter)list.get(i)).getParameterKey(); positions.clear(); for (int j = 1; j < list.size(); j += 2) { Object other = ((Parameter)list.get(j)).getParameterKey(); if (key.equals(other)) positions.add((Integer)list.get(j-1)); } _userParamPositions.put(key, positions.toArray(new Integer[positions.size()])); } }
@Override public Value toValue(ExpressionFactory factory, CriteriaQueryImpl<?> q) { Class<?> clzz = getJavaType(); Object paramKey = _name == null ? _index : _name; boolean isCollectionValued = Collection.class.isAssignableFrom(clzz); org.apache.openjpa.kernel.exps.Parameter param = isCollectionValued ? factory.newCollectionValuedParameter(paramKey, clzz) : factory.newParameter(paramKey, clzz); param.setIndex(_index); return param; }
public static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver, OrderedMap<Object,Class<?>> parameterTypes, String currentQuery) { AbstractExpressionBuilder.setImplicitTypes(val1, val2, expected, resolver); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; if (expected == null) checkEmbeddable(path, currentQuery); Class<?> type = path.getType(); if (type == null) return; Object paramKey = param.getParameterKey(); if (paramKey == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramKey)) parameterTypes.put(paramKey, type); }
public static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver, OrderedMap<Object,Class<?>> parameterTypes, String currentQuery) { AbstractExpressionBuilder.setImplicitTypes(val1, val2, expected, resolver); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; if (expected == null) checkEmbeddable(path, currentQuery); Class<?> type = path.getType(); if (type == null) return; Object paramKey = param.getParameterKey(); if (paramKey == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramKey)) parameterTypes.put(paramKey, type); }
public static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver, OrderedMap<Object,Class<?>> parameterTypes, String currentQuery) { AbstractExpressionBuilder.setImplicitTypes(val1, val2, expected, resolver); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; if (expected == null) checkEmbeddable(path, currentQuery); Class<?> type = path.getType(); if (type == null) return; Object paramKey = param.getParameterKey(); if (paramKey == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramKey)) parameterTypes.put(paramKey, type); }
public static void setImplicitTypes(Value val1, Value val2, Class<?> expected, Resolver resolver, OrderedMap<Object,Class<?>> parameterTypes, String currentQuery) { AbstractExpressionBuilder.setImplicitTypes(val1, val2, expected, resolver); // as well as setting the types for conversions, we also need to // ensure that any parameters are declared with the correct type, // since the JPA spec expects that these will be validated Parameter param = val1 instanceof Parameter ? (Parameter) val1 : val2 instanceof Parameter ? (Parameter) val2 : null; Path path = val1 instanceof Path ? (Path) val1 : val2 instanceof Path ? (Path) val2 : null; // we only check for parameter-to-path comparisons if (param == null || path == null || parameterTypes == null) return; FieldMetaData fmd = path.last(); if (fmd == null) return; if (expected == null) checkEmbeddable(path, currentQuery); Class<?> type = path.getType(); if (type == null) return; Object paramKey = param.getParameterKey(); if (paramKey == null) return; // make sure we have already declared the parameter if (parameterTypes.containsKey(paramKey)) parameterTypes.put(paramKey, type); }