Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,19 @@ public void run() {
}
}

@BuildStep
@Produce(ServiceStartBuildItem.class)
void closeBuildTimeLogging(List<DevServicesResultBuildItem> devServices) {
if (devServices.isEmpty()) {
((QuarkusClassLoader) Thread.currentThread().getContextClassLoader()).addCloseTask(new Runnable() {
@Override
public void run() {
InitialConfigurator.DELAYED_HANDLER.buildTimeComplete();
}
});
}
}
Comment on lines +567 to +578
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this related? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While it's building at the Initial JDK 17 job, It highlighted an error there when I checked that class I found there is a method duplicated which is

void closeBuildTimeLogging(List devServices)

`
@Mac quarkus % grep -n "closeBuildTimeLogging" core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java
343: // When there is no devservices build time logging is still closed at deployment classloader close #closeBuildTimeLogging
556: void closeBuildTimeLogging(List devServices) {
569: void closeBuildTimeLogging(List devServices) {

`


private static boolean allRootMinLevelOrHigher(
int rootMinLogLevel,
Map<String, CategoryBuildTimeConfig> categories,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@
import io.quarkus.runtime.configuration.RuntimeOverrideConfigSourceBuilder;
import io.quarkus.runtime.configuration.StaticInitConfigBuilder;
import io.smallrye.config.ConfigMappingInterface;
import io.smallrye.config.ConfigMappingLoader;
import io.smallrye.config.ConfigMappingMetadata;
import io.smallrye.config.ConfigMappings;
import io.smallrye.config.ConfigMappings.ConfigClass;
import io.smallrye.config.ConfigSourceFactory;
Expand Down Expand Up @@ -677,13 +675,6 @@ private static Map<Object, FieldDescriptor> generateSharedConfig(
clinit.writeStaticField(mappingField, clinit.invokeStaticMethod(CONFIG_CLASS,
clinit.load(mapping.getType().getName()), clinit.load(mapping.getPrefix())));

// Cache implementation types of nested elements
List<ConfigMappingMetadata> configMappingsMetadata = ConfigMappingLoader
.getConfigMappingsMetadata(mapping.getType());
for (ConfigMappingMetadata configMappingMetadata : configMappingsMetadata) {
clinit.invokeStaticMethod(ENSURE_LOADED, clinit.load(configMappingMetadata.getInterfaceType().getName()));
}

Comment on lines -680 to -686
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, changes in this file seem unrelated.

fields.put(mapping, mappingField);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.util.List;

import jakarta.inject.Inject;
import jakarta.transaction.Transactional;

import org.hibernate.FlushMode;
import org.hibernate.Session;
import org.hibernate.cfg.AvailableSettings;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Test;
Expand All @@ -32,7 +35,9 @@ public class ConfigPropertiesTest {
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".packages", MyEntityForOverridesPU.class.getPackageName())
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".datasource", "<default>")
// Overrides to test that Quarkus configuration properties are taken into account
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".flush.mode", "always");
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".flush.mode", "always")
.overrideConfigKey("quarkus.hibernate-orm.\"overrides\".database.extra-physical-table-types",
"MATERIALIZED VIEW,FOREIGN TABLE");

@Inject
Session sessionForDefaultPU;
Expand All @@ -48,4 +53,19 @@ public void propertiesAffectingSession() {
assertThat(sessionForOverridesPU.getHibernateFlushMode()).isEqualTo(FlushMode.ALWAYS);
}

@Test
@Transactional
public void extraPhysicalTableTypes() {
Object extraPhysicalTableTypes = sessionForOverridesPU.getProperties()
.get(AvailableSettings.EXTRA_PHYSICAL_TABLE_TYPES);

assertThat(extraPhysicalTableTypes).isNotNull();
assertThat(extraPhysicalTableTypes).isInstanceOf(List.class);

@SuppressWarnings("unchecked")
List<String> tableTypes = (List<String>) extraPhysicalTableTypes;

assertThat(tableTypes).containsExactly("MATERIALIZED VIEW", "FOREIGN TABLE");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,14 @@ private static void injectDataSource(String persistenceUnitName, String dataSour

private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersistenceUnit persistenceUnitConfig,
Builder runtimeSettingsBuilder) {

// Pass extraPhysicalTableTypes configuration
List<String> extraPhysicalTableTypes = persistenceUnitConfig.schemaManagement().extraPhysicalTableTypes();
if (extraPhysicalTableTypes != null && !extraPhysicalTableTypes.isEmpty()) {
String extraTableTypesStr = String.join(",", extraPhysicalTableTypes);
runtimeSettingsBuilder.put(AvailableSettings.EXTRA_PHYSICAL_TABLE_TYPES, extraTableTypesStr);
}

// Database
runtimeSettingsBuilder.put(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
persistenceUnitConfig.database().generation().generation()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.hibernate.orm.runtime;

import java.util.List;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -161,6 +162,20 @@ interface HibernateOrmConfigPersistenceUnitSchemaManagement {
*/
@WithDefault("false")
boolean haltOnError();

/**
* Additional database object types to include in schema management operations.
*
* By default, Hibernate ORM only considers tables and sequences when performing
* schema management operations.
* This setting allows you to specify additional database object types that should be included,
* such as "MATERIALIZED VIEW", "VIEW", or other database-specific object types.
*
* The exact supported values depend on the underlying database and dialect.
*
* @asciidoclet
*/
List<@WithConverter(TrimmedStringConverter.class) String> extraPhysicalTableTypes();
}

@ConfigGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,13 @@ private void registerVertxAndPool(String persistenceUnitName,

private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersistenceUnit persistenceUnitConfig,
Builder runtimeSettingsBuilder) {

// Pass extraPhysicalTableTypes configuration
List<String> extraPhysicalTableTypes = persistenceUnitConfig.schemaManagement().extraPhysicalTableTypes();
if (extraPhysicalTableTypes != null && !extraPhysicalTableTypes.isEmpty()) {
String extraTableTypesStr = String.join(",", extraPhysicalTableTypes);
runtimeSettingsBuilder.put(AvailableSettings.EXTRA_PHYSICAL_TABLE_TYPES, extraTableTypesStr);
}
// Database
runtimeSettingsBuilder.put(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
persistenceUnitConfig.database().generation().generation()
Expand Down
Loading