Skip to content

Commit

Permalink
#274 Delete setting Hibernate dialects at compile-time in WikiHiberna…
Browse files Browse the repository at this point in the history
…teUtil
  • Loading branch information
mawiesne committed Nov 9, 2023
1 parent 153d748 commit 0cfbb27
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private static Properties getProperties(DatabaseConfiguration config)
boolean useMySQL = false;
boolean useMariaDB = false;
boolean useHSQL = false;
// XXX other dialects might be interesting here as well...
// XXX other backends might be interesting here as well...
if (jdbcURL.toLowerCase().contains("mysql")) {
useMySQL = true;
}
Expand All @@ -86,17 +86,6 @@ else if (jdbcURL.toLowerCase().contains("hsql")) {
useHSQL = true;
}

// SQL dialect
if (useMySQL) {
p.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
}
else if (useMariaDB) {
p.setProperty("hibernate.dialect", "org.hibernate.dialect.MariaDBDialect");
}
else if (useHSQL) {
p.setProperty("hibernate.dialect", "org.hibernate.dialect.HSQLDialect");
}

// Database connection settings
p.setProperty("hibernate.connection.driver_class", databaseDriverClass);
p.setProperty("hibernate.connection.url", jdbcURL);
Expand Down Expand Up @@ -130,12 +119,10 @@ else if (useHSQL) {
p.setProperty("hibernate.hbm2ddl.auto", "none");
}

// Avoid long running connection acquisition:
// Important performance fix to obtain jdbc connections a lot faster by avoiding metadata
// fetching
p.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "false");
// Leave this set 'true' as
p.setProperty("hibernate.temp.use_jdbc_metadata_defaults", "true");

if (useMySQL) {
if (useMySQL || useMariaDB) {
// Set C3P0 Connection Pool in case somebody wants to use it in production settings
// if no C3P0 is available at runtime, related warnings can be ignored safely as the
// built-in CP will be used.
Expand Down

0 comments on commit 0cfbb27

Please sign in to comment.