示例#1
0
  private Object getParameterInputValue(ParameterHint parameterHint) throws DataException {
    assert parameterHint.isInputMode();
    Class paramHintDataType = parameterHint.getDataType();

    // since a Date may have extended types,
    // use the type of Date that is most effective for data conversion
    if (paramHintDataType == Date.class)
      paramHintDataType = parameterHint.getEffectiveDataType(dataSource.getDriverName(), queryType);

    Object inputValue = parameterHint.getDefaultInputValue();
    if (inputValue != null) {
      if (inputValue.getClass().isArray() && !(inputValue instanceof byte[])) {
        // if multi-value type report parameter is linked with data set parameter
        // only take the first provided value to pass it to data set, except for byte[] Object
        if (Array.getLength(inputValue) == 0) {
          inputValue = null;
        } else {
          inputValue = Array.get(inputValue, 0);
        }
      }
    }
    // neither IBlob nor IClob will be converted
    if (paramHintDataType != IBlob.class && paramHintDataType != IClob.class)
      inputValue = convertToValue(inputValue, paramHintDataType);
    return inputValue;
  }
示例#2
0
  /*
   * Prepare a query specification with the property and input parameter values,
   * for use by an ODA driver before IQuery#prepare.
   */
  @SuppressWarnings("restriction")
  private QuerySpecification populateQuerySpecification() throws DataException {
    if (this.querySpecificaton == null) {
      QuerySpecHelper querySpecHelper = new QuerySpecHelper(dataSource.getDriverName(), queryType);
      this.querySpecificaton = querySpecHelper.getFactoryHelper().createQuerySpecification();
    }
    // add custom properties
    addPropertiesToQuerySpec(querySpecificaton);

    // add parameter defns
    addParametersToQuerySpec(querySpecificaton);

    return querySpecificaton;
  }