Package org.springframework.dao

Examples of org.springframework.dao.DataIntegrityViolationException


    // HiveClient MetaStore Thrift API exceptions
    if (ex instanceof TBase) {
      // meta exceptions
      if (ex instanceof AlreadyExistsException || ex instanceof IndexAlreadyExistsException) {
        return new DataIntegrityViolationException(ex.toString(), ex);
      }
      if (ex instanceof ConfigValSecurityException) {
        return new PermissionDeniedDataAccessException(ex.toString(), ex);
      }
      // fallback
View Full Code Here


  public static DataAccessException translateException(RepositoryException ex) {
    if (ex instanceof AccessDeniedException) {
      return new DataRetrievalFailureException("Access denied to this data", ex);
    }
    if (ex instanceof ConstraintViolationException) {
      return new DataIntegrityViolationException("Constraint has been violated", ex);
    }
    if (ex instanceof InvalidItemStateException) {
      return new ConcurrencyFailureException("Invalid item state", ex);
    }
    if (ex instanceof InvalidQueryException) {
      return new DataRetrievalFailureException("Invalid query", ex);
    }
    if (ex instanceof InvalidSerializedDataException) {
      return new DataRetrievalFailureException("Invalid serialized data", ex);
    }
    if (ex instanceof ItemExistsException) {
      return new DataIntegrityViolationException("An item already exists", ex);
    }
    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) {
      return new DataIntegrityViolationException("Referential integrity violated", ex);
    }
    if (ex instanceof UnsupportedRepositoryOperationException) {
      return new InvalidDataAccessApiUsageException("Unsupported operation", ex);
    }
    if (ex instanceof ValueFormatException) {
      return new InvalidDataAccessApiUsageException("Incorrect value format", ex);
    }
    if (ex instanceof VersionException) {
      return new DataIntegrityViolationException("Invalid version graph operation", ex);
    }
    // fallback
    return new JcrSystemException(ex);
  }
View Full Code Here

    }

    if (ex instanceof ObservedException
            || ex instanceof ObservedTimeoutException
            || ex instanceof ObservedModifiedException) {
      return new DataIntegrityViolationException(ex.getMessage(), ex);
    }

    if (ex instanceof CancellationException) {
      throw new OperationCancellationException(ex.getMessage(), ex);
    }
View Full Code Here

   
    public Map<UUID, EventStream<E>> eventStreams = new HashMap<UUID, EventStream<E>>();
   
    public void createEventStream(UUID streamId, EventSource<E> source) {
        if (eventStreams.containsKey(streamId)) {
            throw new DataIntegrityViolationException("stream already exists " + streamId);
        }
        eventStreams.put(streamId, new EventStream<E>(source.getType(), source.getVersion(), source.getTimestamp(), source.getEvents()));
    }
View Full Code Here

    public synchronized void createNewToken(PersistentRememberMeToken token) {
        PersistentRememberMeToken current = seriesTokens.get(token.getSeries());

        if (current != null) {
            throw new DataIntegrityViolationException("Series Id '"+ token.getSeries() +"' already exists!");
        }

        seriesTokens.put(token.getSeries(), token);
    }
View Full Code Here

    public void testUserExistsException() {
        // set expectations
        final User user = new User("admin");
        user.setEmail("matt@raibledesigns.com");

        willThrow(new DataIntegrityViolationException("")).given(userDao).saveUser(user);

        // run test
        try {
            userManager.saveUser(user);
            fail("Expected UserExistsException not thrown");
View Full Code Here

                        } else {
                            log.warn("PersonDirectory::getParameters(): Unrecognized tag ["
                                            + tagname + "] in PersonDirs.xml");
                        }
                    } catch (Throwable t) {
                        throw new DataIntegrityViolationException("Error processing tag [" +
                                tagname + "] with value [" + value + "] in PersonDirInfo [" +
                                dirinfo + "]", t);
                    }
                   
                  
                }

            String validationMessage = pdi.validate();
            if (validationMessage != null)
                throw new DataIntegrityViolationException("Processing PersonDirInfo " +
                        "element [" + dirinfo + "] resulted in an invalid" +
                                " PersonDirInfo object: " + validationMessage);
            infos.add(pdi); // Add one LDAP or JDBC source to the list
        }
        return infos;
View Full Code Here

    }
    if (ex instanceof LockAcquisitionException) {
      return new CannotAcquireLockException(ex.getMessage(), ex);
    }
    if (ex instanceof ConstraintViolationException) {
      return new DataIntegrityViolationException(ex.getMessage(), ex);
    }
    if (ex instanceof JDBCException) {
      return new HibernateJdbcException((JDBCException) ex);
    }
    if (ex instanceof PropertyValueException) {
      return new DataIntegrityViolationException(ex.getMessage(), ex);
    }
    if (ex instanceof PersistentObjectException) {
      return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
    }
    if (ex instanceof TransientObjectException) {
View Full Code Here

      String classCode = sqlState.substring(0, 2);
      if (BAD_SQL_CODES.contains(classCode)) {
        return new BadSqlGrammarException(task, sql, ex);
      }
      else if (INTEGRITY_VIOLATION_CODES.contains(classCode)) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (RESOURCE_FAILURE_CODES.contains(classCode)) {
        return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
      }
      else if (CONCURRENCY_CODES.contains(classCode)) {
View Full Code Here

          logTranslation(task, sql, sqlExToUse, false);
          return new PermissionDeniedDataAccessException(buildMessage(task, sql, sqlExToUse), sqlExToUse);
        }
        else if (Arrays.binarySearch(this.sqlErrorCodes.getDataIntegrityViolationCodes(), errorCode) >= 0) {
          logTranslation(task, sql, sqlExToUse, false);
          return new DataIntegrityViolationException(buildMessage(task, sql, sqlExToUse), sqlExToUse);
        }
        else if (Arrays.binarySearch(this.sqlErrorCodes.getCannotAcquireLockCodes(), errorCode) >= 0) {
          logTranslation(task, sql, sqlExToUse, false);
          return new CannotAcquireLockException(buildMessage(task, sql, sqlExToUse), sqlExToUse);
        }
View Full Code Here

TOP

Related Classes of org.springframework.dao.DataIntegrityViolationException

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.