Java Code Examples for org.springframework.jdbc.support.SQLExceptionTranslator#translate()

The following examples show how to use org.springframework.jdbc.support.SQLExceptionTranslator#translate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GrailsHibernateTemplate.java    From gorm-hibernate5 with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("SqlDialectInspection")
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator) {
    String msg = ex.getMessage();
    String sql = ex.getSQL();
    SQLException sqlException = ex.getSQLException();
    return translator.translate("Hibernate operation: " + msg, sql, sqlException);
}
 
Example 2
Source File: JooqExceptionTranslator.java    From micronaut-sql with Apache License 2.0 4 votes vote down vote up
private DataAccessException translate(ExecuteContext context,
        SQLExceptionTranslator translator, SQLException exception) {
    return translator.translate("jOOQ", context.sql(), exception);
}
 
Example 3
Source File: HibernateAccessor.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Convert the given SQLException to an appropriate exception from the
 * {@code org.springframework.dao} hierarchy. Can be overridden in subclasses.
 * <p>Note that a direct SQLException can just occur when callback code
 * performs direct JDBC access via {@code Session.connection()}.
 * @param ex the SQLException
 * @return the corresponding DataAccessException instance
 * @see #setJdbcExceptionTranslator
 */
protected DataAccessException convertJdbcAccessException(SQLException ex) {
	SQLExceptionTranslator translator = getJdbcExceptionTranslator();
	if (translator == null) {
		translator = getDefaultJdbcExceptionTranslator();
	}
	return translator.translate("Hibernate-related JDBC operation", null, ex);
}
 
Example 4
Source File: HibernateAccessor.java    From spring4-understanding with Apache License 2.0 3 votes vote down vote up
/**
 * Convert the given SQLException to an appropriate exception from the
 * {@code org.springframework.dao} hierarchy. Can be overridden in subclasses.
 * <p>Note that a direct SQLException can just occur when callback code
 * performs direct JDBC access via {@code Session.connection()}.
 * @param ex the SQLException
 * @return the corresponding DataAccessException instance
 * @see #setJdbcExceptionTranslator
 */
protected DataAccessException convertJdbcAccessException(SQLException ex) {
	SQLExceptionTranslator translator = getJdbcExceptionTranslator();
	if (translator == null) {
		translator = getDefaultJdbcExceptionTranslator();
	}
	return translator.translate("Hibernate-related JDBC operation", null, ex);
}
 
Example 5
Source File: HibernateAccessor.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert the given Hibernate JDBCException to an appropriate exception
 * from the {@code org.springframework.dao} hierarchy, using the
 * given SQLExceptionTranslator.
 * @param ex Hibernate JDBCException that occured
 * @param translator the SQLExceptionTranslator to use
 * @return a corresponding DataAccessException
 */
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator) {
	return translator.translate("Hibernate operation: " + ex.getMessage(), ex.getSQL(), ex.getSQLException());
}
 
Example 6
Source File: HibernateTransactionManager.java    From lams with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Convert the given Hibernate JDBCException to an appropriate exception
 * from the {@code org.springframework.dao} hierarchy, using the
 * given SQLExceptionTranslator.
 * @param ex Hibernate JDBCException that occurred
 * @param translator the SQLExceptionTranslator to use
 * @return a corresponding DataAccessException
 */
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator) {
	return translator.translate("Hibernate flushing: " + ex.getMessage(), ex.getSQL(), ex.getSQLException());
}
 
Example 7
Source File: HibernateAccessor.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Convert the given Hibernate JDBCException to an appropriate exception
 * from the {@code org.springframework.dao} hierarchy, using the
 * given SQLExceptionTranslator.
 * @param ex Hibernate JDBCException that occured
 * @param translator the SQLExceptionTranslator to use
 * @return a corresponding DataAccessException
 */
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator) {
	return translator.translate("Hibernate operation: " + ex.getMessage(), ex.getSQL(), ex.getSQLException());
}
 
Example 8
Source File: HibernateTransactionManager.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Convert the given Hibernate JDBCException to an appropriate exception
 * from the {@code org.springframework.dao} hierarchy, using the
 * given SQLExceptionTranslator.
 * @param ex Hibernate JDBCException that occurred
 * @param translator the SQLExceptionTranslator to use
 * @return a corresponding DataAccessException
 */
protected DataAccessException convertJdbcAccessException(JDBCException ex, SQLExceptionTranslator translator) {
	return translator.translate("Hibernate flushing: " + ex.getMessage(), ex.getSQL(), ex.getSQLException());
}