Package org.springframework.dao

Examples of org.springframework.dao.TypeMismatchDataAccessException


    String result = queryForString(query, arguments);
    if (result != null) {
      try {
        return Integer.valueOf(result);
      } catch (NumberFormatException ex) {
        throw new TypeMismatchDataAccessException("Invalid int result found [" + result + "]", ex);
      }
    }
    return null;
  }
View Full Code Here


    String result = queryForString(query, arguments);
    if (result != null) {
      try {
        return Long.valueOf(result);
      } catch (NumberFormatException ex) {
        throw new TypeMismatchDataAccessException("Invalid long result found [" + result + "]", ex);
      }
    }
    return null;
  }
View Full Code Here

      else if (Number.class.isAssignableFrom(requiredType) && Number.class.isInstance(result)) {
        try {
          result = NumberUtils.convertNumberToTargetClass(((Number) result), requiredType);
        }
        catch (IllegalArgumentException ex) {
          throw new TypeMismatchDataAccessException(ex.getMessage());
        }
      }
      else {
        throw new TypeMismatchDataAccessException(
            "Result object is of type [" + result.getClass().getName() +
            "] and could not be converted to required type [" + requiredType.getName() + "]");
      }
    }
    return result;
View Full Code Here

    }
    if (ex instanceof ConcurrencyException) {
      return new ConcurrencyFailureException(ex.getMessage(), ex);
    }
    if (ex instanceof ConversionException) {
      return new TypeMismatchDataAccessException(ex.getMessage(), ex);
    }
    // fallback
    return new TopLinkSystemException(ex);
  }
View Full Code Here

      // Extracted value does not match already: try to convert it.
      try {
        return convertValueToRequiredType(result, this.requiredType);
      }
      catch (IllegalArgumentException ex) {
        throw new TypeMismatchDataAccessException(
            "Type mismatch affecting row number " + rowNum + " and column type '" +
            rsmd.getColumnTypeName(1) + "': " + ex.getMessage());
      }
    }
    return result;
View Full Code Here

   * @return the value of the function
   */
  public int run(Object[] parameters) {
    Object obj = super.findObject(parameters);
    if (!(obj instanceof Number)) {
      throw new TypeMismatchDataAccessException("Couldn't convert result object [" + obj + "] to int");
    }
    return ((Number) obj).intValue();
  }
View Full Code Here

    }
    if (ex instanceof ConcurrencyException) {
      return new ConcurrencyFailureException(ex.getMessage(), ex);
    }
    if (ex instanceof ConversionException) {
      return new TypeMismatchDataAccessException(ex.getMessage(), ex);
    }
    // fallback
    return new TopLinkSystemException(ex);
  }
View Full Code Here

      // Extracted value does not match already: try to convert it.
      try {
        return convertValueToRequiredType(result, this.requiredType);
      }
      catch (IllegalArgumentException ex) {
        throw new TypeMismatchDataAccessException(
            "Type mismatch affecting row number " + rowNum + " and column type '" +
            rsmd.getColumnTypeName(1) + "': " + ex.getMessage());
      }
    }
    return result;
View Full Code Here

            else if (Number.class.isAssignableFrom(this.requiredType) && Number.class.isInstance(result)) {
                try {
                    result = NumberUtils.convertNumberToTargetClass(((Number) result), this.requiredType);
                }
                catch (IllegalArgumentException ex) {
                    throw new TypeMismatchDataAccessException(ex.getMessage());
                }
            }
            else {
                throw new TypeMismatchDataAccessException(
                        "Result object with column type '" + rsmd.getColumnTypeName(1) +
                        "' and value [" + result + "] is of type [" + rsmd.getColumnClassName(1) +
                        "] and could not be converted to required type [" + this.requiredType.getName() + "]");
            }
        }
View Full Code Here

      else if (Number.class.isAssignableFrom(requiredType) && Number.class.isInstance(result)) {
        try {
          result = NumberUtils.convertNumberToTargetClass(((Number) result), (Class<? extends Number>) requiredType);
        }
        catch (IllegalArgumentException ex) {
          throw new TypeMismatchDataAccessException(ex.getMessage());
        }
      }
      else {
        throw new TypeMismatchDataAccessException(
            "Result object is of type [" + result.getClass().getName() +
            "] and could not be converted to required type [" + requiredType.getName() + "]");
      }
    }
    return (T) result;
View Full Code Here

TOP

Related Classes of org.springframework.dao.TypeMismatchDataAccessException

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.