Package org.springframework.dao

Examples of org.springframework.dao.InvalidDataAccessApiUsageException


   * @see org.hibernate.FlushMode#MANUAL
   */
  protected void checkWriteOperationAllowed(Session session) throws InvalidDataAccessApiUsageException {
    if (isCheckWriteOperations() && getFlushMode() != FLUSH_EAGER &&
        session.getFlushMode().lessThan(FlushMode.COMMIT)) {
      throw new InvalidDataAccessApiUsageException(
          "Write operations are not allowed in read-only mode (FlushMode.NEVER/MANUAL): "+
          "Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition.");
    }
  }
View Full Code Here


      if (this.inParameterMapper != null) {
        this.inParameters = this.inParameterMapper.createMap(con);
      }
      else {
        if (this.inParameters == null) {
          throw new InvalidDataAccessApiUsageException(
              "A ParameterMapper or a Map of parameters must be provided");
        }
      }

      CallableStatement cs = null;
      if (resultSetType == ResultSet.TYPE_FORWARD_ONLY && !updatableResults) {
        cs = con.prepareCall(callString);
      }
      else {
        cs = con.prepareCall(callString, resultSetType,
            updatableResults ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
      }

      // Determine CallabeStatement to pass to custom types.
      CallableStatement csToUse = cs;
      if (nativeJdbcExtractor != null) {
        csToUse = nativeJdbcExtractor.getNativeCallableStatement(cs);
      }

      int sqlColIndx = 1;
      for (int i = 0; i < declaredParameters.size(); i++) {
        SqlParameter declaredParam = (SqlParameter) declaredParameters.get(i);
        if (!declaredParam.isResultsParameter()) {
          // So, it's a call parameter - part of the call string.
          // Get the value - it may still be null.
          Object inValue = this.inParameters.get(declaredParam.getName());
          if (declaredParam instanceof ResultSetSupportingSqlParameter) {
            // It's an output parameter: SqlReturnResultSet parameters already excluded.
            // It need not (but may be) supplied by the caller.
            if (declaredParam instanceof SqlOutParameter) {
              if (declaredParam.getTypeName() != null) {
                cs.registerOutParameter(sqlColIndx, declaredParam.getSqlType(), declaredParam.getTypeName());
              }
              else {
                if (declaredParam.getScale() != null) {
                  cs.registerOutParameter(sqlColIndx, declaredParam.getSqlType(), declaredParam.getScale().intValue());
                }
                else {
                  cs.registerOutParameter(sqlColIndx, declaredParam.getSqlType());
                }
              }
              if (declaredParam.isInputValueProvided()) {
                StatementCreatorUtils.setParameterValue(csToUse, sqlColIndx, declaredParam, inValue);
              }
            }
          }
          else {
            // It's an input parameter; must be supplied by the caller.
            if (!this.inParameters.containsKey(declaredParam.getName())) {
              throw new InvalidDataAccessApiUsageException(
                  "Required input parameter '" + declaredParam.getName() + "' is missing");
            }
            StatementCreatorUtils.setParameterValue(csToUse, sqlColIndx, declaredParam, inValue);
          }
          sqlColIndx++;
View Full Code Here

    if (this.mappedClass == null) {
      initialize(mappedClass);
    }
    else {
      if (!this.mappedClass.equals(mappedClass)) {
        throw new InvalidDataAccessApiUsageException("The mapped class can not be reassigned to map to " +
            mappedClass + " since it is already providing mapping for " + this.mappedClass);
      }
    }
  }
View Full Code Here

        }
      }
    }

    if (populatedProperties != null && !populatedProperties.equals(this.mappedProperties)) {
      throw new InvalidDataAccessApiUsageException("Given ResultSet does not contain all fields " +
          "necessary to populate object of class [" + this.mappedClass + "]: " + this.mappedProperties);
    }

    return mappedObject;
  }
View Full Code Here

  public Number getKey() throws InvalidDataAccessApiUsageException, DataRetrievalFailureException {
    if (this.keyList.size() == 0) {
      return null;
    }
    if (this.keyList.size() > 1 || ((Map) this.keyList.get(0)).size() > 1) {
      throw new InvalidDataAccessApiUsageException(
          "The getKey method should only be used when a single key is returned.  " +
          "The current key entry contains multiple keys: " + this.keyList);
    }
    Iterator keyIter = ((Map) this.keyList.get(0)).values().iterator();
    if (keyIter.hasNext()) {
View Full Code Here

  public Map getKeys() throws InvalidDataAccessApiUsageException {
    if (this.keyList.size() == 0) {
      return null;
    }
    if (this.keyList.size() > 1)
      throw new InvalidDataAccessApiUsageException(
          "The getKeys method should only be used when keys for a single row are returned.  " +
          "The current key list contains keys for multiple rows: " + this.keyList);
    return (Map) this.keyList.get(0);
  }
View Full Code Here

   * updatable ResultSets.
   * @see java.sql.Connection#prepareStatement(String, int, int)
   */
  public void setUpdatableResults(boolean updatableResults) {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException(
          "The updateableResults flag must be set before the operation is compiled");
    }
    this.updatableResults = updatableResults;
  }
View Full Code Here

   * auto-generated keys.
   * @see java.sql.Connection#prepareStatement(String, int)
   */
  public void setReturnGeneratedKeys(boolean returnGeneratedKeys) {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException(
          "The returnGeneratedKeys flag must be set before the operation is compiled");
    }
    this.returnGeneratedKeys = returnGeneratedKeys;
  }
View Full Code Here

   * Set the column names of the auto-generated keys.
   * @see java.sql.Connection#prepareStatement(String, String[])
   */
  public void setGeneratedKeysColumnNames(String[] names) {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException(
          "The column names for the generated keys must be set before the operation is compiled");
    }
    this.generatedKeysColumnNames = names;
  }
View Full Code Here

   * <code>java.sql.Types</code> class
   * @throws InvalidDataAccessApiUsageException if the operation is already compiled
   */
  public void setTypes(int[] types) throws InvalidDataAccessApiUsageException {
    if (isCompiled()) {
      throw new InvalidDataAccessApiUsageException("Cannot add parameters once query is compiled");
    }
    if (types != null) {
      for (int i = 0; i < types.length; i++) {
        declareParameter(new SqlParameter(types[i]));
      }
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.