Spring DAO Repository exception handling

Anything the DAO throws will be unchecked. Don't catch anything in the DAO. If you catch exceptions in the DAO or within the service method, Spring won't know to rollback the transaction. Configure exception-handling at the controller layer (using an exception handler, not with try-catch), that is where the data access exceptions will usually be caught, because there is nothing to do to handle them except to log them.


That means if you are using Spring Abstraction for JDBC, JPA/Hibernate or JDO then you don't have to implement JDBC or RDBMS vendor specific error handling. So Spring wraps all those exceptions and then wraps them into DataAccessException class. When you want to switch to different persistence technology, you don't have to worry about refractoring your code.