Skip to content

Commit

Permalink
Merge pull request #26838 from yrodiere/hsearch-cleanups
Browse files Browse the repository at this point in the history
Various cleanups and minor fixes for the Hibernate ORM and Hibernate Search extensions
  • Loading branch information
Sanne authored Jul 20, 2022
2 parents d3b6187 + 4b69107 commit dee4549
Show file tree
Hide file tree
Showing 81 changed files with 264 additions and 175 deletions.
1 change: 0 additions & 1 deletion docs/src/main/asciidoc/hibernate-orm.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ For instance, the following snippet defines a default datasource and a default p
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:default;DB_CLOSE_DELAY=-1
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create
----

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,6 @@ and sets the Elasticsearch host for that persistence unit to `es1.mycompany.com:
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:default;DB_CLOSE_DELAY=-1
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-search-orm.elasticsearch.hosts=es1.mycompany.com:9200
quarkus.hibernate-search-orm.elasticsearch.version=7
----
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quarkus.hibernate-orm.datasource=ds-1
quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.discriminator.ignore-explicit-for-joined=true
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=none
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.implicit-naming-strategy=io.quarkus.hibernate.orm.naming.CustomImplicitNamingStrategy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.sql-load-script=import.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.sql-load-script=import-1.sql,import-2.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.database.generation.halt-on-error=true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.log.sql=true
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.log.format-sql=false
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.mapping-files=my-hbm.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.mapping-files=my-orm.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.mapping-files=no-file
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.metadata-builder-contributor=io.quarkus.hibernate.orm.metadatabuildercontributor.CustomMetadataBuilderContributor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.metrics.enabled=true
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ quarkus.datasource.users.jdbc.min-size=2

quarkus.datasource.inventory.db-kind=h2

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.datasource=<default>

quarkus.hibernate-orm."users".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."users".database.generation=drop-and-create
quarkus.hibernate-orm."users".datasource=users

quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."inventory".database.generation=drop-and-create
quarkus.hibernate-orm."inventory".datasource=inventory
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:mem:inventory

quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."inventory".database.generation=drop-and-create
quarkus.hibernate-orm."inventory".datasource=inventory
quarkus.hibernate-orm."inventory".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.inventory
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.users.db-kind=h2
quarkus.datasource.users.jdbc.url=jdbc:h2:tcp://localhost/mem:users

quarkus.hibernate-orm."users".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."users".log.sql=true
quarkus.hibernate-orm."users".database.generation=drop-and-create
quarkus.hibernate-orm."users".datasource=users
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ quarkus.datasource.users.jdbc.url=jdbc:h2:mem:users
quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:mem:inventory

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config

quarkus.hibernate-orm."users".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."users".database.generation=drop-and-create
quarkus.hibernate-orm."users".datasource=users
quarkus.hibernate-orm."users".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.user

quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."inventory".database.generation=drop-and-create
quarkus.hibernate-orm."inventory".datasource=inventory
quarkus.hibernate-orm."inventory".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.inventory
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ quarkus.datasource.users.jdbc.url=jdbc:h2:mem:users
quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:mem:inventory

quarkus.hibernate-orm."users".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."users".database.generation=drop-and-create
quarkus.hibernate-orm."users".datasource=users
quarkus.hibernate-orm."users".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.user

quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."inventory".database.generation=drop-and-create
quarkus.hibernate-orm."inventory".datasource=inventory
quarkus.hibernate-orm."inventory".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.inventory
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ quarkus.datasource.users.jdbc.url=jdbc:h2:mem:users
quarkus.datasource.inventory.db-kind=h2
quarkus.datasource.inventory.jdbc.url=jdbc:h2:mem:inventory

quarkus.hibernate-orm."users".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."users".database.generation=drop-and-create
quarkus.hibernate-orm."users".datasource=users
quarkus.hibernate-orm."users".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.user
quarkus.hibernate-orm."users".discriminator.ignore-explicit-for-joined=true

quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."inventory".database.generation=drop-and-create
quarkus.hibernate-orm."inventory".datasource=inventory
quarkus.hibernate-orm."inventory".packages=io.quarkus.hibernate.orm.multiplepersistenceunits.model.config.inventory
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.users.db-kind=h2
quarkus.datasource.users.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.datasource=users
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
quarkus.hibernate-orm.pu-1.datasource=ds-1
quarkus.hibernate-orm.pu-1.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.pu-1.log.sql=true
quarkus.hibernate-orm.pu-1.database.generation=drop-and-create
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
quarkus.hibernate-orm.pu-1.dialect=org.hibernate.dialect.H2Dialect
# We need at least one build-time property, otherwise the PU gets ignored...
quarkus.hibernate-orm.pu-1.packages=io.quarkus.hibernate.orm.config.namedpu
quarkus.hibernate-orm.pu-1.log.sql=true
quarkus.hibernate-orm.pu-1.database.generation=drop-and-create
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
#quarkus.hibernate-orm.sql-load-script=load-script-test.sql
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.sql-load-script=load-script-test.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.physical-naming-strategy=io.quarkus.hibernate.orm.naming.PrefixPhysicalNamingStrategy
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:test

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
#quarkus.hibernate-orm.log.sql=true
quarkus.hibernate-orm.database.generation=drop-and-create
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchIntegrationRuntimeConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchIntegrationStaticConfiguredBuildItem;
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit;

class HibernateSearchOutboxPollingProcessor {

Expand Down Expand Up @@ -76,7 +77,11 @@ void setRuntimeConfig(HibernateSearchOutboxPollingRecorder recorder,
}

private boolean isUsingOutboxPolling(HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem persistenceUnit) {
Optional<String> configuredStrategy = persistenceUnit.getBuildTimeConfig().coordination.strategy;
HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit puConfig = persistenceUnit.getBuildTimeConfig();
if (puConfig == null) {
return false;
}
Optional<String> configuredStrategy = puConfig.coordination.strategy;
return configuredStrategy.isPresent()
&& configuredStrategy.get().equals(HibernateOrmMapperOutboxPollingSettings.COORDINATION_STRATEGY_NAME);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@ quarkus.datasource.jdbc.url=jdbc:h2:mem:default;DB_CLOSE_DELAY=-1
quarkus.datasource.data1.db-kind=h2
quarkus.datasource.data1.jdbc.url=jdbc:h2:mem:data1;DB_CLOSE_DELAY=-1

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.hibernate-orm.datasource=<default>

quarkus.hibernate-search-orm.elasticsearch.version=7
quarkus.hibernate-search-orm.elasticsearch.hosts=${elasticsearch.hosts:localhost:9200}
quarkus.hibernate-search-orm.elasticsearch.protocol=${elasticsearch.protocol:http}
quarkus.hibernate-search-orm.schema-management.strategy=drop-and-create-and-drop
quarkus.hibernate-search-orm.coordination.strategy=outbox-polling

quarkus.hibernate-orm."pu1".dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm."pu1".database.generation=drop-and-create
quarkus.hibernate-orm."pu1".datasource=data1

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
quarkus.datasource.db-kind=h2
quarkus.datasource.jdbc.url=jdbc:h2:mem:default;DB_CLOSE_DELAY=-1

quarkus.hibernate-orm.dialect=org.hibernate.dialect.H2Dialect
quarkus.hibernate-orm.database.generation=drop-and-create

quarkus.hibernate-search-orm.elasticsearch.version=7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@ public final class HibernateSearchElasticsearchPersistenceUnitConfiguredBuildIte

private final String persistenceUnitName;
private final HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit buildTimeConfig;
private final boolean defaultBackendIsUsed;
private final Set<String> backendNamesForIndexedEntities;
private Map<String, Set<String>> backendAndIndexNamesForSearchExtensions;

public HibernateSearchElasticsearchPersistenceUnitConfiguredBuildItem(String persistenceUnitName,
HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit buildTimeConfig, boolean defaultBackendIsUsed,
HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit buildTimeConfig,
Set<String> backendNamesForIndexedEntities,
Map<String, Set<String>> backendAndIndexNamesForSearchExtensions) {
if (persistenceUnitName == null) {
throw new IllegalArgumentException("persistenceUnitName cannot be null");
}
this.persistenceUnitName = persistenceUnitName;
this.buildTimeConfig = buildTimeConfig;
this.defaultBackendIsUsed = defaultBackendIsUsed;
this.backendNamesForIndexedEntities = backendNamesForIndexedEntities;
this.backendAndIndexNamesForSearchExtensions = backendAndIndexNamesForSearchExtensions;
}

Expand All @@ -33,8 +34,8 @@ public HibernateSearchElasticsearchBuildTimeConfigPersistenceUnit getBuildTimeCo
return buildTimeConfig;
}

public boolean isDefaultBackendUsed() {
return defaultBackendIsUsed;
public Set<String> getBackendNamesForIndexedEntities() {
return backendNamesForIndexedEntities;
}

public Map<String, Set<String>> getBackendAndIndexNamesForSearchExtensions() {
Expand Down
Loading

0 comments on commit dee4549

Please sign in to comment.