-
Notifications
You must be signed in to change notification settings - Fork 2
Exception Translation
Philippe Marschall edited this page Oct 12, 2016
·
2 revisions
There different ways are provided how you can handle exceptions:
- If the method declares
throws SQLException
no exception translation will happen and the original exception will be propagated. - If the does not method declare
throws SQLException
exception translation to anUncheckedSQLException
will happen. - If the does not method declare
throws SQLException
exception and Spring is present translation will happen using SpringDataAccessException
hierarchy. - should none of these meet your needs you can implement you own
SQLExceptionAdapter
For example if your method looks like this
public interface TaxProcedures {
BigDecimal salesTax(BigDecimal subtotal) throws SQLException;
}
then you will get the original SQLException
. However if your method looks like this
public interface TaxProcedures {
BigDecimal salesTax(BigDecimal subtotal); // no throws SQLException
}
you will get a UncheckedSQLException
unless Spring is present. In that case you will get a DataAccessException
or subclass.
-
Usage
-
Integration