Package org.hibernate.exception

Examples of org.hibernate.exception.ConstraintViolationException


          throw new LockTimeoutException( message, sqlException, sql );
        }
        if ( 515 == errorCode && "ZZZZZ".equals( sqlState ) ) {
          // Attempt to insert NULL value into column; column does not allow nulls.
          final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
          return new ConstraintViolationException( message, sqlException, sql, constraintName );
        }
        return null;
      }
    };
  }
View Full Code Here


      if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
        return new SQLGrammarException( message, sqlException, sql );
      }
      else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( errorCode ) ) {
        String constraintName = extracter.extractConstraintName( sqlException );
        return new ConstraintViolationException( message, sqlException, sql, constraintName );
      }
      else if ( CONNECTION_CATEGORIES.contains( sqlStateClassCode ) ) {
        return new JDBCConnectionException( message, sqlException, sql );
      }
      else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) {
View Full Code Here

        if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
          return new SQLGrammarException( message, sqlException, sql );
        }
        else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( sqlStateClassCode ) ) {
          String constraintName = extracter.extractConstraintName( sqlException );
          return new ConstraintViolationException( message, sqlException, sql, constraintName );
        }
        else if ( CONNECTION_CATEGORIES.contains( sqlStateClassCode ) ) {
          return new JDBCConnectionException( message, sqlException, sql );
        }
        else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) {
View Full Code Here

        }
        else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( sqlStateClassCode ) ) {
          final String constraintName = getConversionContext()
              .getViolatedConstraintNameExtracter()
              .extractConstraintName( sqlException );
          return new ConstraintViolationException( message, sqlException, sql, constraintName );
        }
        else if ( CONNECTION_CATEGORIES.contains( sqlStateClassCode ) ) {
          return new JDBCConnectionException( message, sqlException, sql );
        }
        else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) {
View Full Code Here

      if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
        return new SQLGrammarException( message, sqlException, sql );
      }
      else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( errorCode ) ) {
        String constraintName = extracter.extractConstraintName( sqlException );
        return new ConstraintViolationException( message, sqlException, sql, constraintName );
      }
      else if ( CONNECTION_CATEGORIES.contains( sqlStateClassCode ) ) {
        return new JDBCConnectionException( message, sqlException, sql );
      }
      else if ( DATA_CATEGORIES.contains( sqlStateClassCode ) ) {
View Full Code Here

          }

          if ( 90006 == errorCode ) {
            // NULL not allowed for column [90006-145]
            final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
            return new ConstraintViolationException( message, sqlException, sql, constraintName );
          }

          return null;
        }
      };
View Full Code Here

        // 462 - failed on update or delete by foreign key constraint violation
        if ( errorCode == 287 || errorCode == 301 || errorCode == 461 || errorCode == 462 ) {
          final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName(
              sqlException );

          return new ConstraintViolationException( message, sqlException, sql, constraintName );
        }

        return null;
      }
    };
View Full Code Here

          }

          if ( 90006 == errorCode ) {
            // NULL not allowed for column [90006-145]
            final String constraintName = getViolatedConstraintNameExtracter().extractConstraintName( sqlException );
            return new ConstraintViolationException( message, sqlException, sql, constraintName );
          }

          return null;
        }
      };
View Full Code Here

    if (ex instanceof PessimisticLockException) {
      PessimisticLockException jdbcEx = (PessimisticLockException) ex;
      return new PessimisticLockingFailureException(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);
    }
    // end of JDBCException (subclass) handling
View Full Code Here

    if (ex instanceof PessimisticLockException) {
      PessimisticLockException jdbcEx = (PessimisticLockException) ex;
      return new PessimisticLockingFailureException(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);
    }
    // end of JDBCException subclass handling

    if (ex instanceof QueryException) {
      return new InvalidDataAccessResourceUsageException(ex.getMessage(), ex);
View Full Code Here

TOP

Related Classes of org.hibernate.exception.ConstraintViolationException

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.