Package org.springframework.dao

Examples of org.springframework.dao.InvalidDataAccessApiUsageException


      if (generatedKeyColumnsUsed) {
        logger.info("Unable to locate non-key columns for table '" +
            this.getTableName() + "' so an empty insert statement is generated");
      }
      else {
        throw new InvalidDataAccessApiUsageException("Unable to locate columns for table '" +
            this.getTableName() + "' so an insert statement can't be generated");
      }
    }
    for (int i = 0; i < columnCount; i++) {
      if (i > 0) {
View Full Code Here


   * @return the array of values
   */
  public static Object[] buildValueArray(ParsedSql parsedSql, SqlParameterSource paramSource, List declaredParams) {
    Object[] paramArray = new Object[parsedSql.getTotalParameterCount()];
    if (parsedSql.getNamedParameterCount() > 0 && parsedSql.getUnnamedParameterCount() > 0) {
      throw new InvalidDataAccessApiUsageException(
          "You can't mix named and traditional ? placeholders. You have " +
          parsedSql.getNamedParameterCount() + " named parameter(s) and " +
          parsedSql.getUnnamedParameterCount() + " traditonal placeholder(s) in [" +
          parsedSql.getOriginalSql() + "]");
    }
    List paramNames = parsedSql.getParameterNames();
    for (int i = 0; i < paramNames.size(); i++) {
      String paramName = (String) paramNames.get(i);
      try {
        Object value = paramSource.getValue(paramName);
        SqlParameter param = findParameter(declaredParams, paramName, i);
        paramArray[i] = (param != null ? new SqlParameterValue(param, value) : value);
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(
            "No value supplied for the SQL parameter '" + paramName + "': " + ex.getMessage());
      }
    }
    return paramArray;
  }
View Full Code Here

    else {
      if (this.metaDataProvider.isRefCursorSupported()) {
        return new SqlOutParameter(parameterName, this.metaDataProvider.getRefCursorSqlType(), rowMapper);
      }
      else {
        throw new InvalidDataAccessApiUsageException("Return of a ResultSet from a stored procedure is not supported.");
      }
    }
  }
View Full Code Here

          parameter = declaredParameters.get(this.getFunctionReturnName());
          if (parameter == null && this.getOutParameterNames().size() > 0) {
            parameter = declaredParameters.get(this.getOutParameterNames().get(0).toLowerCase());
          }
          if (parameter == null) {
            throw new InvalidDataAccessApiUsageException(
                "Unable to locate declared parameter for function return value - " +
                    " add an SqlOutParameter with name \"" + getFunctionReturnName() +"\"");
          }
          else {
            this.setFunctionReturnName(parameter.getName());
View Full Code Here

            this.currSql = sql[i];
            if (!stmt.execute(sql[i])) {
              rowsAffected[i] = stmt.getUpdateCount();
            }
            else {
              throw new InvalidDataAccessApiUsageException("Invalid batch SQL statement: " + sql[i]);
            }
          }
        }
        return rowsAffected;
      }
View Full Code Here

            this.currSql = sql[i];
            if (!stmt.execute(sql[i])) {
              rowsAffected[i] = stmt.getUpdateCount();
            }
            else {
              throw new InvalidDataAccessApiUsageException("Invalid batch SQL statement: " + sql[i]);
            }
          }
        }
        return rowsAffected;
      }
View Full Code Here

   * as <code>SqlOutParameter</code>.
   * @param parameter the {@link SqlParameter} to add
   */
  public void addDeclaredParameter(SqlParameter parameter) {
    if (!StringUtils.hasText(parameter.getName())) {
      throw new InvalidDataAccessApiUsageException("You must specify a parameter name when declaring parameters for \"" + getProcedureName() + "\"");
    }
    this.declaredParameters.add(parameter);
    if (logger.isDebugEnabled()) {
      logger.debug("Added declared parameter for [" + getProcedureName() + "]: " + parameter.getName());
    }
View Full Code Here

   * been correctly initialized, for example if no DataSource has been provided
   */
  public final void compile() throws InvalidDataAccessApiUsageException {
    if (!isCompiled()) {
      if (getProcedureName() == null) {
        throw new InvalidDataAccessApiUsageException("Procedure or Function name is required");
      }

      try {
        this.jdbcTemplate.afterPropertiesSet();
      }
      catch (IllegalArgumentException ex) {
        throw new InvalidDataAccessApiUsageException(ex.getMessage());
      }

      compileInternal();
      this.compiled = true;

View Full Code Here

                  "."+procs.getString("PROCEDURE_SCHEM") +
                  "."+procs.getString("PROCEDURE_NAME"));
      }
      procs.close();
      if (found.size() > 1) {
        throw new InvalidDataAccessApiUsageException("Unable to determine the correct call signature - " +
            "multiple procedures/functions/signatures for " + metaDataProcedureName + " found " + found);
      }
      if (found.size() < 1) {
        if (metaDataProcedureName.contains(".") && !StringUtils.hasText(metaDataCatalogName)) {
          String packageName = metaDataProcedureName.substring(0, metaDataProcedureName.indexOf("."));
          throw new InvalidDataAccessApiUsageException("Unable to determine the correct call signature for " +
              metaDataProcedureName + " - package name should be specified separately using " +
              "'.withCatalogName(\"" + packageName + "\")'");
        }
      }
View Full Code Here

          else {
            names.add("Parameter #" + i);
          }
        }
        if (names.size() != declaredParameters.size()) {
          throw new InvalidDataAccessApiUsageException(
              "SQL [" + sql + "]: given " + names.size() +
              " parameters but expected " + declaredParameters.size());
        }
      }
    }
View Full Code Here

TOP

Related Classes of org.springframework.dao.InvalidDataAccessApiUsageException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.