Spring makes SQL error codes redundant

Originally Posted by
gdboling
... before using Spring, we were sending the SQLException's getErrorCode() to our own PersistenceException. DataAccessException doesn't have a getErrorCode method, so what is the best way to retrieve that, if any.
The beauty of Spring's DataAccessException hierarchy is that it provides a handy abstraction from the vendor-specific error codes reported by different JDBC drivers. Your "tier above the service tier" only needs to check which specific subclass of DataAccessException has been thrown; it doesn't know or care which db product is actually being used.
If you wanted to retain your PersistenceException class, perhaps you could modify its constructor (or its factory, if it has one) to take a DataAccessException as a parameter (at which point it could do whatever it needed with it).
Andrew Swan
"Now is the EJB of our discontent made glorious Spring"