diff --git a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchProcessor.java b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchProcessor.java index 53cbfdb401b89..d6a830014ca79 100644 --- a/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchProcessor.java +++ b/extensions/hibernate-search-orm-elasticsearch/deployment/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchProcessor.java @@ -160,7 +160,7 @@ private void buildForPersistenceUnit(HibernateSearchElasticsearchRecorder record // we need a runtime listener even when Hibernate Search is disabled, // just to let Hibernate Search boot up until the point where it checks whether it's enabled or not runtimeIntegrations.produce(new HibernateOrmIntegrationRuntimeConfiguredBuildItem(HIBERNATE_SEARCH_ELASTICSEARCH, - persistenceUnitName).setInitListener(recorder.createDisabledRuntimeInitListener(persistenceUnitName))); + persistenceUnitName).setInitListener(recorder.createDisabledRuntimeInitListener())); return; } diff --git a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java index b78ebc371b5bc..bf7af08b6e495 100644 --- a/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java +++ b/extensions/hibernate-search-orm-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/orm/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java @@ -74,9 +74,8 @@ public HibernateOrmIntegrationRuntimeInitListener createRuntimeInitListener( backendAndIndexNamesForSearchExtensions, integrationRuntimeInitListeners); } - public HibernateOrmIntegrationRuntimeInitListener createDisabledRuntimeInitListener(String persistenceUnitName) { - return new HibernateSearchIntegrationRuntimeInitListener(persistenceUnitName, null, Collections.emptyMap(), - Collections.emptyList()); + public HibernateOrmIntegrationRuntimeInitListener createDisabledRuntimeInitListener() { + return new HibernateSearchIntegrationRuntimeInitDisabledListener(); } public Supplier searchMappingSupplier(HibernateSearchElasticsearchRuntimeConfig runtimeConfig, @@ -261,6 +260,28 @@ private void contributeBackendIndexBuildTimeProperties(BiConsumer propertyCollector) { + // Not strictly necessary since this should be set during static init, + // but let's be on the safe side. + propertyCollector.accept(HibernateOrmMapperSettings.ENABLED, false); + } + + @Override + public List> contributeServiceInitiators() { + return List.of( + // The service must be initiated even if Hibernate Search is disabled, + // because it's also responsible for determining that Hibernate Search is disabled. + new HibernateSearchPreIntegrationService.Initiator()); + } + } + private static final class HibernateSearchIntegrationRuntimeInitListener implements HibernateOrmIntegrationRuntimeInitListener {