Fix missing-driver in HibernateSchemaExporterTest (#777)

* Fix missing-driver in HibernateSchemaExporterTest

HibernateSchemaExporterTest is failing with "Driver not found" error
after Java 11 upgrade. Reason is that ServiceLoader now only checks
modules for services.

Proper fix is to define modules.

This short term fix is to declare the driver class explicitly.
This commit is contained in:
Weimin Yu 2020-08-24 10:20:19 -04:00 committed by GitHub
parent 2418876c15
commit f36b05462f

View file

@ -59,6 +59,9 @@ public class HibernateSchemaExporter {
settings.put(Environment.USER, username);
settings.put(Environment.PASS, password);
settings.put(Environment.HBM2DDL_AUTO, "none");
// Register driver explicitly to work around ServiceLoader change after Java 8.
// Driver self-registration only works if driver is declared in a module.
settings.put(Environment.DRIVER, "org.postgresql.Driver");
settings.put(Environment.SHOW_SQL, "true");
settings.put(
Environment.PHYSICAL_NAMING_STRATEGY, NomulusNamingStrategy.class.getCanonicalName());