Package org.springframework.dao

Examples of org.springframework.dao.DataAccessResourceFailureException


    // Thrift client exception
    if (ex instanceof HiveServerException) {
      return convert((HiveServerException) ex);
    }
    if (ex instanceof TException) {
      return new DataAccessResourceFailureException(ex.getMessage(), ex);
    }

    // HiveClient MetaStore Thrift API exceptions
    if (ex instanceof TBase) {
      // meta exceptions
View Full Code Here


    PARSER_EXCEPTION = cls;
  }
 
  static DataAccessException convert(PigException ex) {
    if (ex instanceof BackendException) {
      return new DataAccessResourceFailureException("Backend Pig exception", ex);
    }

    if (ex instanceof VisitorException || ex instanceof PlanException || ex instanceof SchemaMergeException) {
      return new InvalidDataAccessResourceUsageException("Plan failed", ex);
    }
View Full Code Here

      throws DataAccessException {
    try {
      return doGetSession(sessionFactory, allowCreate);
    }
    catch (RepositoryException ex) {
      throw new DataAccessResourceFailureException("Could not open Jcr Session", ex);
    }
  }
View Full Code Here

    }
    if (ex instanceof ItemNotFoundException) {
      return new DataRetrievalFailureException("Item not found", ex);
    }
    if (ex instanceof LoginException) {
      return new DataAccessResourceFailureException("Bad login", ex);
    }
    if (ex instanceof LockException) {
      return new ConcurrencyFailureException("Item is locked", ex);
    }
    if (ex instanceof MergeException) {
      return new DataIntegrityViolationException("Merge failed", ex);
    }
    if (ex instanceof NamespaceException) {
      return new InvalidDataAccessApiUsageException("Namespace not registred", ex);
    }
    if (ex instanceof NoSuchNodeTypeException) {
      return new InvalidDataAccessApiUsageException("No such node type", ex);
    }
    if (ex instanceof NoSuchWorkspaceException) {
      return new DataAccessResourceFailureException("Workspace not found", ex);
    }
    if (ex instanceof PathNotFoundException) {
      return new DataRetrievalFailureException("Path not found", ex);
    }
    if (ex instanceof ReferentialIntegrityException) {
View Full Code Here

   *
   * @param ex
   * @return
   */
  public static DataAccessException translateException(IOException ex) {
    return new DataAccessResourceFailureException("I/O failure", ex);
  }
View Full Code Here

   */
  @Override
  public final DataAccessException translateExceptionIfPossible(final RuntimeException ex) {

    if (ex instanceof ConnectionException) {
      return new DataAccessResourceFailureException(ex.getMessage(), ex);
    }

    if (ex instanceof ObservedException
            || ex instanceof ObservedTimeoutException
            || ex instanceof ObservedModifiedException) {
View Full Code Here

                            columnValues.add(new PersistentValue(pf.getColumnName(), pf.getSqlType(), r));
                        }
                    }

                } catch (NoSuchMethodException e1) {
                    throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
                } catch (IllegalAccessException e1) {
                    throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
                } catch (InvocationTargetException e1) {
                    throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
                }
            }
            else {
                unmappedFields.put(pf.getFieldName(), pf);
            }
View Full Code Here

        Object[] idValue = new Object[1];
        try {
            Method m = o.getClass().getMethod(ActiveMapperUtils.getterName(pf.getFieldName()), new Class[] {});
            idValue[0] = m.invoke(o, new Object[] {});
        } catch (NoSuchMethodException e1) {
            throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
        } catch (IllegalAccessException e1) {
            throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
        } catch (InvocationTargetException e1) {
            throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(pf.getFieldName()).append(".").toString(), e1);
        }
        getJdbcTemplate().update(sql, idValue);
    }
View Full Code Here

            this.mappedClass = clazz;
            this.persistentObject = persistentObject;
            try {
                defaultConstruct = mappedClass.getConstructor(null);
            } catch (NoSuchMethodException e) {
                throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to access default constructor of ").append(mappedClass.getName()).toString(), e);
            }
        }
View Full Code Here

        public Object mapRow(ResultSet rs, int rowNumber) throws SQLException {
            Object result;
            try {
                result = defaultConstruct.newInstance(null);
            } catch (IllegalAccessException e) {
                throw new DataAccessResourceFailureException("Failed to load class " + mappedClass.getName(), e);
            } catch (InvocationTargetException e) {
                throw new DataAccessResourceFailureException("Failed to load class " + mappedClass.getName(), e);
            } catch (InstantiationException e) {
                throw new DataAccessResourceFailureException("Failed to load class " + mappedClass.getName(), e);
            }
            ResultSetMetaData meta = rs.getMetaData();
            int columns = meta.getColumnCount();
            Map mappedColumns = new HashMap(10);
            Map unmappedColumns = new HashMap(10);
            for (int x = 1; x <= columns; x++) {
                String field = meta.getColumnName(x).toLowerCase();
                PersistentField fieldMeta = (PersistentField)persistentObject.getPersistentFields().get(field);
                if (fieldMeta != null) {
                    Object value = null;
                    Method m = null;
                    try {
                        if (fieldMeta.getJavaType().equals(String.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {String.class});
                            value = rs.getString(x);
                        }
                        else if (fieldMeta.getJavaType().equals(Byte.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Byte.class});
                            value = new Byte(rs.getByte(x));
                        }
                        else if (fieldMeta.getJavaType().equals(Short.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Short.class});
                            value = new Short(rs.getShort(x));
                        }
                        else if (fieldMeta.getJavaType().equals(Integer.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Integer.class});
                            value = new Integer(rs.getInt(x));
                        }
                        else if (fieldMeta.getJavaType().equals(Long.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Long.class});
                            value = new Long(rs.getLong(x));
                        }
                        else if (fieldMeta.getJavaType().equals(Float.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Float.class});
                            value = new Float(rs.getFloat(x));
                        }
                        else if (fieldMeta.getJavaType().equals(Double.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Double.class});
                            value = new Double(rs.getDouble(x));
                        }
                        else if (fieldMeta.getJavaType().equals(BigDecimal.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {BigDecimal.class});
                            value = rs.getBigDecimal(x);
                        }
                        else if (fieldMeta.getJavaType().equals(Boolean.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Boolean.class});
                            value = (rs.getBoolean(x)) ? Boolean.TRUE : Boolean.FALSE;
                        }
                        else if (fieldMeta.getJavaType().equals(Date.class)) {
                            m = result.getClass().getMethod(ActiveMapperUtils.setterName(fieldMeta.getColumnName()), new Class[] {Date.class});
                            if (fieldMeta.getSqlType() == Types.DATE) {
                                value = rs.getDate(x);
                            }
                            else if (fieldMeta.getSqlType() == Types.TIME) {
                                value = rs.getTime(x);
                            }
                            else {
                                value = rs.getTimestamp(x);
                            }
                        }
                        else {
                            unmappedColumns.put(fieldMeta.getColumnName(), fieldMeta);
                        }
                        if (m != null) {
                            m.invoke(result , new Object[] {value});
                            mappedColumns.put(meta.getColumnName(x), meta);
                        }
                    } catch (NoSuchMethodException e) {
                        throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(fieldMeta.getFieldName()).append(".").toString(), e);
                    } catch (IllegalAccessException e) {
                        throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(fieldMeta.getFieldName()).append(".").toString(), e);
                    } catch (InvocationTargetException e) {
                        throw new DataAccessResourceFailureException(new StringBuffer().append("Failed to map field ").append(fieldMeta.getFieldName()).append(".").toString(), e);
                    }
                }
                else {
                    unmappedColumns.put(meta.getColumnName(x), meta);
                }
View Full Code Here

TOP

Related Classes of org.springframework.dao.DataAccessResourceFailureException

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.