Example usage for org.hibernate.exception DataException DataException

List of usage examples for org.hibernate.exception DataException DataException

Introduction

In this page you can find the example usage for org.hibernate.exception DataException DataException.

Prototype

public DataException(String message, SQLException root, String sql) 

Source Link

Document

Constructor for JDBCException.

Usage

From source file:com.enigmabridge.hibernate.dialect.SQLiteDialect.java

License:unlicense.org

@Override
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
    return new SQLExceptionConversionDelegate() {
        @Override/*w w w.  jav a2 s .c o m*/
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final int errorCode = org.hibernate.internal.util.JdbcExceptionHelper
                    .extractErrorCode(sqlException);
            if (errorCode == SQLITE_CONSTRAINT) {
                final String constraintName = EXTRACTER.extractConstraintName(sqlException);
                return new ConstraintViolationException(message, sqlException, sql, constraintName);
            } else if (errorCode == SQLITE_TOOBIG || errorCode == SQLITE_MISMATCH) {
                return new DataException(message, sqlException, sql);
            } else if (errorCode == SQLITE_BUSY || errorCode == SQLITE_LOCKED) {
                return new LockAcquisitionException(message, sqlException, sql);
            } else if ((errorCode >= SQLITE_IOERR && errorCode <= SQLITE_PROTOCOL)
                    || errorCode == SQLITE_NOTADB) {
                return new JDBCConnectionException(message, sqlException, sql);
            }
            return new GenericJDBCException(message, sqlException, sql);
        }
    };
}

From source file:com.vmware.sqlfire.hibernate.SQLFireDialect.java

License:Open Source License

public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
    return new SQLExceptionConversionDelegate() {
        @Override/*  w  w w  .j  a v a 2 s.  co  m*/
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final String sqlState = JdbcExceptionHelper.extractSqlState(sqlException);
            if (sqlState != null) {
                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                    return new SQLGrammarException(message, sqlException, sql);
                } else if (DATA_CATEGORIES.contains(sqlState)) {
                    return new DataException(message, sqlException, sql);
                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                    return new LockAcquisitionException(message, sqlException, sql);
                }
            }
            return null;
        }
    };
}

From source file:com.vmware.sqlfire.hibernate.v3.SQLFireDialect.java

License:Open Source License

@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
    return new SQLExceptionConverter() {
        @Override// w  w  w  .ja  v a  2s  .c  o m
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final String sqlState = JDBCExceptionHelper.extractSqlState(sqlException);
            if (sqlState != null) {
                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                    return new SQLGrammarException(message, sqlException, sql);
                } else if (DATA_CATEGORIES.contains(sqlState)) {
                    return new DataException(message, sqlException, sql);
                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                    return new LockAcquisitionException(message, sqlException, sql);
                }
            }
            return new JDBCException(message, sqlException, sql);
        }
    };
}

From source file:com.vmware.sqlfire.hibernate.v4.v0.SQLFireDialect.java

License:Open Source License

@Override
public SQLExceptionConverter buildSQLExceptionConverter() {
    return new SQLExceptionConverter() {
        @Override/* w ww . j av a 2 s . co m*/
        public JDBCException convert(SQLException sqlException, String message, String sql) {
            final String sqlState = JdbcExceptionHelper.extractSqlState(sqlException);
            if (sqlState != null) {
                if (SQL_GRAMMAR_CATEGORIES.contains(sqlState)) {
                    return new SQLGrammarException(message, sqlException, sql);
                } else if (DATA_CATEGORIES.contains(sqlState)) {
                    return new DataException(message, sqlException, sql);
                } else if (LOCK_ACQUISITION_CATEGORIES.contains(sqlState)) {
                    return new LockAcquisitionException(message, sqlException, sql);
                }
            }
            return new JDBCException(message, sqlException, sql);
        }
    };
}