Skip to content

Commit

Permalink
Register org.postgresql.jdbc.PgConnection.getSchema method
Browse files Browse the repository at this point in the history
Co-authored-by: Yoann Rodière <[email protected]>
  • Loading branch information
zakkak and yrodiere committed Jan 23, 2025
1 parent 1954123 commit e35f992
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem;
import io.quarkus.deployment.index.IndexingUtil;
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
Expand Down Expand Up @@ -311,6 +312,7 @@ public void configurationDescriptorBuilding(
BuildProducer<NativeImageResourceBuildItem> nativeImageResources,
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles,
BuildProducer<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptors,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
List<DatabaseKindDialectBuildItem> dbKindMetadataBuildItems) {

if (!hasEntities(jpaModel)) {
Expand Down Expand Up @@ -348,7 +350,7 @@ public void configurationDescriptorBuilding(
handleHibernateORMWithNoPersistenceXml(hibernateOrmConfig, index, persistenceXmlDescriptors,
jdbcDataSources, applicationArchivesBuildItem, launchMode.getLaunchMode(), jpaModel, capabilities,
systemProperties, nativeImageResources, hotDeploymentWatchedFiles, persistenceUnitDescriptors,
dbKindMetadataBuildItems);
reflectiveMethods, dbKindMetadataBuildItems);
}
}

Expand Down Expand Up @@ -824,6 +826,7 @@ private void handleHibernateORMWithNoPersistenceXml(
BuildProducer<NativeImageResourceBuildItem> nativeImageResources,
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles,
BuildProducer<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptors,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
List<DatabaseKindDialectBuildItem> dbKindMetadataBuildItems) {
if (!descriptors.isEmpty()) {
if (hibernateOrmConfig.isAnyNonPersistenceXmlPropertySet()) {
Expand Down Expand Up @@ -872,7 +875,7 @@ private void handleHibernateORMWithNoPersistenceXml(
jpaModel.getXmlMappings(PersistenceUnitUtil.DEFAULT_PERSISTENCE_UNIT_NAME),
jdbcDataSources, applicationArchivesBuildItem, launchMode, capabilities,
systemProperties, nativeImageResources, hotDeploymentWatchedFiles, persistenceUnitDescriptors,
storageEngineCollector, dbKindMetadataBuildItems);
reflectiveMethods, storageEngineCollector, dbKindMetadataBuildItems);
} else if (!modelClassesAndPackagesForDefaultPersistenceUnit.isEmpty()
&& (!hibernateOrmConfig.defaultPersistenceUnit().datasource().isPresent()
|| DataSourceUtil.isDefault(hibernateOrmConfig.defaultPersistenceUnit().datasource().get()))
Expand All @@ -892,7 +895,7 @@ private void handleHibernateORMWithNoPersistenceXml(
jpaModel.getXmlMappings(persistenceUnitEntry.getKey()),
jdbcDataSources, applicationArchivesBuildItem, launchMode, capabilities,
systemProperties, nativeImageResources, hotDeploymentWatchedFiles, persistenceUnitDescriptors,
storageEngineCollector, dbKindMetadataBuildItems);
reflectiveMethods, storageEngineCollector, dbKindMetadataBuildItems);
}

if (storageEngineCollector.size() > 1) {
Expand All @@ -915,6 +918,7 @@ private static void producePersistenceUnitDescriptorFromConfig(
BuildProducer<NativeImageResourceBuildItem> nativeImageResources,
BuildProducer<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles,
BuildProducer<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptors,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
Set<String> storageEngineCollector,
List<DatabaseKindDialectBuildItem> dbKindMetadataBuildItems) {
Optional<JdbcDataSourceBuildItem> jdbcDataSource = findJdbcDataSource(persistenceUnitName, persistenceUnitConfig,
Expand Down Expand Up @@ -943,7 +947,7 @@ private static void producePersistenceUnitDescriptorFromConfig(
MultiTenancyStrategy multiTenancyStrategy = getMultiTenancyStrategy(persistenceUnitConfig.multitenant());
collectDialectConfig(persistenceUnitName, persistenceUnitConfig,
dbKindMetadataBuildItems, jdbcDataSource, multiTenancyStrategy,
systemProperties, descriptor.getProperties()::setProperty, storageEngineCollector);
systemProperties, reflectiveMethods, descriptor.getProperties()::setProperty, storageEngineCollector);

// Physical Naming Strategy
persistenceUnitConfig.physicalNamingStrategy().ifPresent(
Expand Down Expand Up @@ -1134,6 +1138,7 @@ private static void collectDialectConfig(String persistenceUnitName,
List<DatabaseKindDialectBuildItem> dbKindMetadataBuildItems, Optional<JdbcDataSourceBuildItem> jdbcDataSource,
MultiTenancyStrategy multiTenancyStrategy,
BuildProducer<SystemPropertyBuildItem> systemProperties,
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
BiConsumer<String, String> puPropertiesCollector, Set<String> storageEngineCollector) {
Optional<String> explicitDialect = persistenceUnitConfig.dialect().dialect();
Optional<String> dbKind = jdbcDataSource.map(JdbcDataSourceBuildItem::getDbKind);
Expand Down Expand Up @@ -1210,6 +1215,14 @@ private static void collectDialectConfig(String persistenceUnitName,
if (dbProductVersion.isPresent()) {
puPropertiesCollector.accept(AvailableSettings.JAKARTA_HBM2DDL_DB_VERSION, dbProductVersion.get());
}

if ((dbKind.isPresent() && DatabaseKind.isPostgreSQL(dbKind.get())
|| (dialect.isPresent() && dialect.get().toLowerCase(Locale.ROOT).contains("postgres")))) {
// Workaround for https://hibernate.atlassian.net/browse/HHH-19063
reflectiveMethods.produce(new ReflectiveMethodBuildItem(
"Accessed in org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver.determineAppropriateResolverDelegate",
true, "org.postgresql.jdbc.PgConnection", "getSchema"));
}
}

private static void collectDialectConfigForPersistenceXml(String persistenceUnitName,
Expand Down

0 comments on commit e35f992

Please sign in to comment.