Package org.springframework.dao

Examples of org.springframework.dao.DataIntegrityViolationException


        return u;
    }

    public UserAuth createUser(UserAuth u) {
        String userName = u.getUserName();
        if (userExists(userName)) throw new DataIntegrityViolationException(userName);
        u.setCreatedOn(System.currentTimeMillis());
        getHibernateTemplate().save(u);
        return u;
    }
View Full Code Here


        }
        return r;
    }

    public Role createRole(String roleName) {
        if (roleExists(roleName)) throw new DataIntegrityViolationException(roleName);
        Role r = new Role();
        r.setName(roleName);
        getHibernateTemplate().save(r);
        return r;
    }
View Full Code Here

    KeyHolder kh = executeInsertAndReturnKeyHolderInternal(values);
    if (kh != null && kh.getKey() != null) {
      return kh.getKey();
    }
    else {
      throw new DataIntegrityViolationException("Unable to retrieve the generated key for the insert: " +
          getInsertString());
    }
  }
View Full Code Here

      }
      if (BAD_SQL_GRAMMAR_CODES.contains(classCode)) {
        return new BadSqlGrammarException(task, sql, ex);
      }
      else if (DATA_INTEGRITY_VIOLATION_CODES.contains(classCode)) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (DATA_ACCESS_RESOURCE_FAILURE_CODES.contains(classCode)) {
        return new DataAccessResourceFailureException(buildMessage(task, sql, ex), ex);
      }
      else if (TRANSIENT_DATA_ACCESS_RESOURCE_CODES.contains(classCode)) {
View Full Code Here

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

        return new TransientDataAccessResourceException(buildMessage(task, sql, ex), ex);
      }
    }
    else if (ex instanceof SQLNonTransientException) {
      if (ex instanceof SQLDataException) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLFeatureNotSupportedException) {
        return new InvalidDataAccessApiUsageException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLIntegrityConstraintViolationException) {
        return new DataIntegrityViolationException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLInvalidAuthorizationSpecException) {
        return new PermissionDeniedDataAccessException(buildMessage(task, sql, ex), ex);
      }
      else if (ex instanceof SQLNonTransientConnectionException) {
View Full Code Here

      }
      prepareAccount( account );
      return account;
    }
    else {
      throw new DataIntegrityViolationException( "More than one user account for the same username." );
    }
  }
View Full Code Here

      LockAcquisitionException jdbcEx = (LockAcquisitionException) ex;
      return new CannotAcquireLockException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof ConstraintViolationException) {
      ConstraintViolationException jdbcEx = (ConstraintViolationException) ex;
      return new DataIntegrityViolationException(ex.getMessage()  + "; SQL [" + jdbcEx.getSQL() +
          "]; constraint [" + jdbcEx.getConstraintName() + "]", ex);
    }
    if (ex instanceof DataException) {
      DataException jdbcEx = (DataException) ex;
      return new DataIntegrityViolationException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", 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

    }
    if (ex instanceof OptimisticLockException) {
      return new JpaOptimisticLockingFailureException((OptimisticLockException) ex);
    }
    if (ex instanceof EntityExistsException) {
      return new DataIntegrityViolationException(ex.getMessage(), ex);
    }
    if (ex instanceof TransactionRequiredException) {
      return new InvalidDataAccessApiUsageException(ex.getMessage(), ex);
    }
View Full Code Here

    KeyHolder kh = executeInsertAndReturnKeyHolderInternal(values);
    if (kh != null && kh.getKey() != null) {
      return kh.getKey();
    }
    else {
      throw new DataIntegrityViolationException("Unable to retrieve the generated key for the insert: " +
          getInsertString());
    }
  }
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.