@@ -80,43 +80,43 @@ protected DataAccessException doTranslate(String task, @Nullable String sql, SQL
8080
8181 if (sqlEx instanceof SQLTransientException ) {
8282 if (sqlEx instanceof SQLTransientConnectionException ) {
83- return new TransientDataAccessResourceException (buildMessage (task , sql , sqlEx ), sqlEx );
83+ return new TransientDataAccessResourceException (buildMessage (task , sql , sqlEx ), ex );
8484 }
8585 if (sqlEx instanceof SQLTransactionRollbackException ) {
8686 if (SQLStateSQLExceptionTranslator .indicatesCannotAcquireLock (sqlEx .getSQLState ())) {
87- return new CannotAcquireLockException (buildMessage (task , sql , sqlEx ), sqlEx );
87+ return new CannotAcquireLockException (buildMessage (task , sql , sqlEx ), ex );
8888 }
89- return new PessimisticLockingFailureException (buildMessage (task , sql , sqlEx ), sqlEx );
89+ return new PessimisticLockingFailureException (buildMessage (task , sql , sqlEx ), ex );
9090 }
9191 if (sqlEx instanceof SQLTimeoutException ) {
92- return new QueryTimeoutException (buildMessage (task , sql , sqlEx ), sqlEx );
92+ return new QueryTimeoutException (buildMessage (task , sql , sqlEx ), ex );
9393 }
9494 }
9595 else if (sqlEx instanceof SQLNonTransientException ) {
9696 if (sqlEx instanceof SQLNonTransientConnectionException ) {
97- return new DataAccessResourceFailureException (buildMessage (task , sql , sqlEx ), sqlEx );
97+ return new DataAccessResourceFailureException (buildMessage (task , sql , sqlEx ), ex );
9898 }
9999 if (sqlEx instanceof SQLDataException ) {
100- return new DataIntegrityViolationException (buildMessage (task , sql , sqlEx ), sqlEx );
100+ return new DataIntegrityViolationException (buildMessage (task , sql , sqlEx ), ex );
101101 }
102102 if (sqlEx instanceof SQLIntegrityConstraintViolationException ) {
103103 if (SQLStateSQLExceptionTranslator .indicatesDuplicateKey (sqlEx .getSQLState (), sqlEx .getErrorCode ())) {
104- return new DuplicateKeyException (buildMessage (task , sql , sqlEx ), sqlEx );
104+ return new DuplicateKeyException (buildMessage (task , sql , sqlEx ), ex );
105105 }
106- return new DataIntegrityViolationException (buildMessage (task , sql , sqlEx ), sqlEx );
106+ return new DataIntegrityViolationException (buildMessage (task , sql , sqlEx ), ex );
107107 }
108108 if (sqlEx instanceof SQLInvalidAuthorizationSpecException ) {
109- return new PermissionDeniedDataAccessException (buildMessage (task , sql , sqlEx ), sqlEx );
109+ return new PermissionDeniedDataAccessException (buildMessage (task , sql , sqlEx ), ex );
110110 }
111111 if (sqlEx instanceof SQLSyntaxErrorException ) {
112- return new BadSqlGrammarException (task , (sql != null ? sql : "" ), sqlEx );
112+ return new BadSqlGrammarException (task , (sql != null ? sql : "" ), ex );
113113 }
114114 if (sqlEx instanceof SQLFeatureNotSupportedException ) {
115- return new InvalidDataAccessApiUsageException (buildMessage (task , sql , sqlEx ), sqlEx );
115+ return new InvalidDataAccessApiUsageException (buildMessage (task , sql , sqlEx ), ex );
116116 }
117117 }
118118 else if (sqlEx instanceof SQLRecoverableException ) {
119- return new RecoverableDataAccessException (buildMessage (task , sql , sqlEx ), sqlEx );
119+ return new RecoverableDataAccessException (buildMessage (task , sql , sqlEx ), ex );
120120 }
121121
122122 // Fallback to Spring's own SQL state translation...
0 commit comments