Package org.hibernate.exception

Examples of org.hibernate.exception.SQLGrammarException


          sql,
          getConversionContext().getViolatedConstraintNameExtracter().extractConstraintName( sqlException )
      );
    }
    else if ( SQLSyntaxErrorException.class.isInstance( sqlException ) ) {
      return new SQLGrammarException( message, sqlException, sql );
    }
    else if ( SQLTimeoutException.class.isInstance( sqlException ) ) {
      return new QueryTimeoutException( message, sqlException, sql );
    }
    else if ( SQLTransactionRollbackException.class.isInstance( sqlException ) ) {
View Full Code Here


        // 260 - Invalid column name
        // 261 - Invalid index name
        // 262 - Invalid query name
        // 263 - Invalid alias name
        if ( errorCode == 257 || ( errorCode >= 259 && errorCode <= 263 ) ) {
          throw new SQLGrammarException( message, sqlException, sql );
        }

        // 257 - Cannot insert NULL or update to NULL
        // 301 - Unique constraint violated
        // 461 - foreign key constraint violation
View Full Code Here

    if ( sqlState != null ) {
      String sqlStateClassCode = JdbcExceptionHelper.determineSqlStateClassCode( sqlState );

      if ( sqlStateClassCode != null ) {
        if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
          return new SQLGrammarException( message, sqlException, sql );
        }
        else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( sqlStateClassCode ) ) {
          final String constraintName = getConversionContext()
              .getViolatedConstraintNameExtracter()
              .extractConstraintName( sqlException );
View Full Code Here

          sql,
          getConversionContext().getViolatedConstraintNameExtracter().extractConstraintName( sqlException )
      );
    }
    else if ( SQLSyntaxErrorException.class.isInstance( sqlException ) ) {
      return new SQLGrammarException( message, sqlException, sql );
    }
    else if ( SQLTimeoutException.class.isInstance( sqlException ) ) {
      return new QueryTimeoutException( message, sqlException, sql );
    }
    else if ( SQLTransactionRollbackException.class.isInstance( sqlException ) ) {
View Full Code Here

    if ( sqlState != null ) {
      String sqlStateClassCode = JdbcExceptionHelper.determineSqlStateClassCode( sqlState );

      if ( sqlStateClassCode != null ) {
        if ( SQL_GRAMMAR_CATEGORIES.contains( sqlStateClassCode ) ) {
          return new SQLGrammarException( message, sqlException, sql );
        }
        else if ( INTEGRITY_VIOLATION_CATEGORIES.contains( sqlStateClassCode ) ) {
          final String constraintName = getConversionContext()
              .getViolatedConstraintNameExtracter()
              .extractConstraintName( sqlException );
View Full Code Here

          sql,
          getConversionContext().getViolatedConstraintNameExtracter().extractConstraintName( sqlException )
      );
    }
    else if ( SQLSyntaxErrorException.class.isInstance( sqlException ) ) {
      return new SQLGrammarException( message, sqlException, sql );
    }
    else if ( SQLTimeoutException.class.isInstance( sqlException ) ) {
      return new QueryTimeoutException( message, sqlException, sql );
    }
    else if ( SQLTransactionRollbackException.class.isInstance( sqlException ) ) {
View Full Code Here

  public static DataAccessException convertHibernateAccessException(HibernateException ex) {
    if (ex instanceof JDBCConnectionException) {
      return new DataAccessResourceFailureException(ex.getMessage(), ex);
    }
    if (ex instanceof SQLGrammarException) {
      SQLGrammarException jdbcEx = (SQLGrammarException) ex;
      return new InvalidDataAccessResourceUsageException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof LockAcquisitionException) {
      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) {
View Full Code Here

  public static DataAccessException convertHibernateAccessException(HibernateException ex) {
    if (ex instanceof JDBCConnectionException) {
      return new DataAccessResourceFailureException(ex.getMessage(), ex);
    }
    if (ex instanceof SQLGrammarException) {
      SQLGrammarException jdbcEx = (SQLGrammarException) ex;
      return new InvalidDataAccessResourceUsageException(ex.getMessage() + "; SQL [" + jdbcEx.getSQL() + "]", ex);
    }
    if (ex instanceof LockAcquisitionException) {
      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) {
View Full Code Here

      // expected
      assertEquals(jcex, ex.getCause());
      assertTrue(ex.getMessage().indexOf("mymsg") != -1);
    }

    final SQLGrammarException sgex = new SQLGrammarException("mymsg", sqlEx);
    try {
      createTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(org.hibernate.Session session) throws HibernateException {
          throw sgex;
        }
View Full Code Here

  public JDBCException convert(SQLException sqlException, String message, String sql) {
    String sqlStateClassCode = JdbcExceptionHelper.extractSqlStateClassCode( sqlException );
    Integer errorCode = JdbcExceptionHelper.extractErrorCode( sqlException );
    if ( sqlStateClassCode != null ) {
      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 );
      }
View Full Code Here

TOP

Related Classes of org.hibernate.exception.SQLGrammarException

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.