Remove custom Hibernate dialect detection
Closes #27954 Signed-off-by: synth3 <19573241+synth3@users.noreply.github.com>
This commit is contained in:
parent
32541f19a3
commit
99478887a4
1 changed files with 3 additions and 43 deletions
|
@ -210,8 +210,9 @@ public class DefaultJpaConnectionProviderFactory implements JpaConnectionProvide
|
|||
try {
|
||||
prepareOperationalInfo(connection);
|
||||
|
||||
String driverDialect = detectDialect(connection);
|
||||
if (driverDialect != null) {
|
||||
String driverDialect = config.get("driverDialect");
|
||||
// use configured dialect, else rely on Hibernate detection
|
||||
if (driverDialect != null && !driverDialect.isBlank()) {
|
||||
properties.put("hibernate.dialect", driverDialect);
|
||||
}
|
||||
|
||||
|
@ -289,47 +290,6 @@ public class DefaultJpaConnectionProviderFactory implements JpaConnectionProvide
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
protected String detectDialect(Connection connection) {
|
||||
String driverDialect = config.get("driverDialect");
|
||||
if (driverDialect != null && driverDialect.length() > 0) {
|
||||
return driverDialect;
|
||||
} else {
|
||||
try {
|
||||
String dbProductName = connection.getMetaData().getDatabaseProductName();
|
||||
String dbProductVersion = connection.getMetaData().getDatabaseProductVersion();
|
||||
|
||||
// For MSSQL2014, we may need to fix the autodetected dialect by hibernate
|
||||
if (dbProductName.equals("Microsoft SQL Server")) {
|
||||
String topVersionStr = dbProductVersion.split("\\.")[0];
|
||||
boolean shouldSet2012Dialect = true;
|
||||
try {
|
||||
int topVersion = Integer.parseInt(topVersionStr);
|
||||
if (topVersion < 12) {
|
||||
shouldSet2012Dialect = false;
|
||||
}
|
||||
} catch (NumberFormatException nfe) {
|
||||
}
|
||||
if (shouldSet2012Dialect) {
|
||||
String sql2012Dialect = "org.hibernate.dialect.SQLServer2012Dialect";
|
||||
logger.debugf("Manually override hibernate dialect to %s", sql2012Dialect);
|
||||
return sql2012Dialect;
|
||||
}
|
||||
}
|
||||
|
||||
// For Oracle19c, we may need to set dialect explicitly to workaround https://hibernate.atlassian.net/browse/HHH-13184
|
||||
if (dbProductName.equals("Oracle") && connection.getMetaData().getDatabaseMajorVersion() > 12) {
|
||||
logger.debugf("Manually specify dialect for Oracle to org.hibernate.dialect.Oracle12cDialect");
|
||||
return "org.hibernate.dialect.Oracle12cDialect";
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.warnf("Unable to detect hibernate dialect due database exception : %s", e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void startGlobalStats(KeycloakSession session, int globalStatsIntervalSecs) {
|
||||
logger.debugf("Started Hibernate statistics with the interval %s seconds", globalStatsIntervalSecs);
|
||||
TimerProvider timer = session.getProvider(TimerProvider.class);
|
||||
|
|
Loading…
Reference in a new issue