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 8d38086d40
commit c36f0c89c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -59,6 +59,9 @@ public class HibernateSchemaExporter {
settings.put(Environment.USER, username); settings.put(Environment.USER, username);
settings.put(Environment.PASS, password); settings.put(Environment.PASS, password);
settings.put(Environment.HBM2DDL_AUTO, "none"); 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.SHOW_SQL, "true");
settings.put( settings.put(
Environment.PHYSICAL_NAMING_STRATEGY, NomulusNamingStrategy.class.getCanonicalName()); Environment.PHYSICAL_NAMING_STRATEGY, NomulusNamingStrategy.class.getCanonicalName());