views:

219

answers:

1

I'm using JPA in my DAOs outside of Spring . The Spring framework defines DataAccessExceptions that are independent of databases implementations. Is there any advantage for a non Spring user to use the Spring data access exceptions instead of those of JPA ?

I guess that the Spring DataAccessExceptions exist since Spring handle several underlayers, (such Hibernate, Jpa, jdo, jdbc) and that the Spring Data Access Exception stack is usefull only if my application have DAOs using several technologies that have not a common standard interface (such JPA).

Am I right ?

+1  A: 

I'd say you're pretty much there. Another advantage is that there is a family of DataAccessExceptions (CleanupFailure, SQLGrammar, etc off the top of my head), so a DAO can be programmed to explicitly catch a specific exception that you might be expecting.

But since you're usually not expecting a data access error, you usually leave it uncaught anyway, so the full purpose of the DataAccessException isn't usually needed.

(I used to be a huge fan of the DataAccessException hierarchy, but I've actually needed it so rarely that I am now happy to deal with raw JPAException).

Dick Chesterwood