Skip to content

Commit 471ee4a

Browse files
authored
Merge pull request #541 from kazuki43zoo/gh-540_support-spring-5.3
Support Spring 5.3
2 parents fd3352a + 409f54e commit 471ee4a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<osgi.dynamicImport>*</osgi.dynamicImport>
107107

108108
<mybatis.version>3.5.6</mybatis.version>
109-
<spring.version>5.2.9.RELEASE</spring.version>
109+
<spring.version>5.3.0</spring.version>
110110
<spring-batch.version>4.3.0</spring-batch.version>
111111
<module.name>org.mybatis.spring</module.name>
112112

src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.apache.ibatis.exceptions.PersistenceException;
2424
import org.springframework.dao.DataAccessException;
2525
import org.springframework.dao.support.PersistenceExceptionTranslator;
26+
import org.springframework.jdbc.UncategorizedSQLException;
2627
import org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator;
2728
import org.springframework.jdbc.support.SQLExceptionTranslator;
2829
import org.springframework.transaction.TransactionException;
@@ -85,7 +86,10 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) {
8586
}
8687
if (e.getCause() instanceof SQLException) {
8788
this.initExceptionTranslator();
88-
return this.exceptionTranslator.translate(e.getMessage() + "\n", null, (SQLException) e.getCause());
89+
String task = e.getMessage() + "\n";
90+
SQLException se = (SQLException) e.getCause();
91+
DataAccessException dae = this.exceptionTranslator.translate(task, null, se);
92+
return dae != null ? dae : new UncategorizedSQLException(task, null, se);
8993
} else if (e.getCause() instanceof TransactionException) {
9094
throw (TransactionException) e.getCause();
9195
}

0 commit comments

Comments
 (0)