mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Handle non supported JOOQ dialect
This commit uses a fallback translator if the JOOQ Dialect in use is not one we support. Closes gh-8521
This commit is contained in:
parent
cbde6ed096
commit
5d27c7e501
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -36,6 +36,7 @@ import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
|
||||
* @author Lukas Eder
|
||||
* @author Andreas Ahlenstorf
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
class JooqExceptionTranslator extends DefaultExecuteListener {
|
||||
|
||||
@ -58,8 +59,10 @@ class JooqExceptionTranslator extends DefaultExecuteListener {
|
||||
private SQLExceptionTranslator getTranslator(ExecuteContext context) {
|
||||
SQLDialect dialect = context.configuration().dialect();
|
||||
if (dialect != null && dialect.thirdParty() != null) {
|
||||
return new SQLErrorCodeSQLExceptionTranslator(
|
||||
dialect.thirdParty().springDbName());
|
||||
String dbName = dialect.thirdParty().springDbName();
|
||||
if (dbName != null) {
|
||||
return new SQLErrorCodeSQLExceptionTranslator(dbName);
|
||||
}
|
||||
}
|
||||
return new SQLStateSQLExceptionTranslator();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -58,7 +58,8 @@ public class JooqExceptionTranslatorTests {
|
||||
new Object[] { SQLDialect.POSTGRES, sqlException("03000") },
|
||||
new Object[] { SQLDialect.POSTGRES_9_3, sqlException("03000") },
|
||||
new Object[] { SQLDialect.POSTGRES_9_4, sqlException("03000") },
|
||||
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") } };
|
||||
new Object[] { SQLDialect.POSTGRES_9_5, sqlException("03000") },
|
||||
new Object[] { SQLDialect.SQLITE, sqlException("21000") }};
|
||||
}
|
||||
|
||||
private static SQLException sqlException(String sqlState) {
|
||||
|
Loading…
Reference in New Issue
Block a user