diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 87a682ec29e3a..417b7b1033696 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -101,8 +101,8 @@
bytebuddy.version (just below), hibernate-orm.version-for-documentation (in docs/pom.xml)
and both hibernate-orm.version and antlr.version in build-parent/pom.xml
WARNING again for diffs that don't provide enough context: when updating, see above -->
- 6.5.0.Final
- 1.14.12
+ 6.5.2.Final
+ 1.14.15
6.0.6.Final
2.3.0.Final
8.0.1.Final
diff --git a/extensions/hibernate-orm/deployment-spi/src/main/java/io/quarkus/hibernate/orm/deployment/spi/DatabaseKindDialectBuildItem.java b/extensions/hibernate-orm/deployment-spi/src/main/java/io/quarkus/hibernate/orm/deployment/spi/DatabaseKindDialectBuildItem.java
index fe807866175cf..0087e4334b4f7 100644
--- a/extensions/hibernate-orm/deployment-spi/src/main/java/io/quarkus/hibernate/orm/deployment/spi/DatabaseKindDialectBuildItem.java
+++ b/extensions/hibernate-orm/deployment-spi/src/main/java/io/quarkus/hibernate/orm/deployment/spi/DatabaseKindDialectBuildItem.java
@@ -1,6 +1,7 @@
package io.quarkus.hibernate.orm.deployment.spi;
import java.util.Optional;
+import java.util.Set;
import io.quarkus.builder.item.MultiBuildItem;
@@ -9,15 +10,74 @@
*/
public final class DatabaseKindDialectBuildItem extends MultiBuildItem {
private final String dbKind;
- private final String dialect;
+ private final Optional databaseProductName;
+ private final Optional dialect;
+ private final Set matchingDialects;
private final Optional defaultDatabaseProductVersion;
+ /**
+ * @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
+ * @param databaseProductName The corresponding database-product-name to set in Hibernate ORM.
+ * See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
+ * @param dialects The corresponding dialects in Hibernate ORM,
+ * to detect the dbKind when using database multi-tenancy.
+ */
+ public static DatabaseKindDialectBuildItem forCoreDialect(String dbKind, String databaseProductName,
+ Set dialects) {
+ return new DatabaseKindDialectBuildItem(dbKind, Optional.empty(), Optional.of(databaseProductName),
+ dialects, Optional.empty());
+ }
+
+ /**
+ * @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
+ * @param databaseProductName The corresponding database-product-name to set in Hibernate ORM.
+ * See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
+ * @param dialects The corresponding dialects in Hibernate ORM,
+ * to detect the dbKind when using database multi-tenancy.
+ * @param defaultDatabaseProductVersion The default database-product-version to set in Hibernate ORM.
+ * This is useful when the default version of the dialect in Hibernate ORM
+ * is lower than what we expect in Quarkus.
+ */
+ public static DatabaseKindDialectBuildItem forCoreDialect(String dbKind, String databaseProductName,
+ Set dialects, String defaultDatabaseProductVersion) {
+ return new DatabaseKindDialectBuildItem(dbKind, Optional.empty(), Optional.of(databaseProductName),
+ dialects, Optional.of(defaultDatabaseProductVersion));
+ }
+
+ /**
+ * @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
+ * @param dialect The corresponding dialect to set in Hibernate ORM.
+ * See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
+ */
+ public static DatabaseKindDialectBuildItem forThirdPartyDialect(String dbKind, String dialect) {
+ return new DatabaseKindDialectBuildItem(dbKind, Optional.of(dialect), Optional.empty(), Set.of(dialect),
+ Optional.empty());
+ }
+
/**
* @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
* @param dialect The corresponding dialect to set in Hibernate ORM.
+ * See {@code org.hibernate.dialect.Database} for information on how this name is resolved to a dialect.
+ * @param defaultDatabaseProductVersion The default database-product-version to set in Hibernate ORM.
+ * This is useful when the default version of the dialect in Hibernate ORM
+ * is lower than what we expect in Quarkus.
*/
+ public static DatabaseKindDialectBuildItem forThirdPartyDialect(String dbKind, String dialect,
+ String defaultDatabaseProductVersion) {
+ return new DatabaseKindDialectBuildItem(dbKind, Optional.of(dialect), Optional.empty(),
+ Set.of(dialect), Optional.of(defaultDatabaseProductVersion));
+ }
+
+ /**
+ * @param dbKind The DB Kind set through {@code quarkus.datasource.db-kind}
+ * @param dialect The corresponding dialect to set in Hibernate ORM.
+ * @deprecated Use {@link #forCoreDialect(String, String, Set)}(different arguments!)
+ * for core Hibernate ORM dialects to avoid warnings on startup,
+ * or {@link #forThirdPartyDialect(String, String)} for community or third-party dialects.
+ */
+ @Deprecated
public DatabaseKindDialectBuildItem(String dbKind, String dialect) {
- this(dbKind, dialect, Optional.empty());
+ this(dbKind, Optional.of(dialect), Optional.empty(), Set.of(dialect), Optional.empty());
}
/**
@@ -27,15 +87,22 @@ public DatabaseKindDialectBuildItem(String dbKind, String dialect) {
* @param defaultDatabaseProductVersion The default database-product-version to set in Hibernate ORM.
* This is useful when the default version of the dialect in Hibernate ORM
* is lower than what we expect in Quarkus.
+ * @deprecated Use {@link #forCoreDialect(String, String, Set, String)}(different arguments!)
+ * for core Hibernate ORM dialects to avoid warnings on startup,
+ * or {@link #forThirdPartyDialect(String, String, String)} for community or third-party dialects.
*/
+ @Deprecated
public DatabaseKindDialectBuildItem(String dbKind, String dialect, String defaultDatabaseProductVersion) {
- this(dbKind, dialect, Optional.of(defaultDatabaseProductVersion));
+ this(dbKind, Optional.of(dialect), Optional.empty(), Set.of(dialect), Optional.of(defaultDatabaseProductVersion));
}
- private DatabaseKindDialectBuildItem(String dbKind, String dialect,
+ private DatabaseKindDialectBuildItem(String dbKind, Optional dialect,
+ Optional databaseProductName, Set matchingDialects,
Optional defaultDatabaseProductVersion) {
this.dbKind = dbKind;
this.dialect = dialect;
+ this.matchingDialects = matchingDialects;
+ this.databaseProductName = databaseProductName;
this.defaultDatabaseProductVersion = defaultDatabaseProductVersion;
}
@@ -44,9 +111,21 @@ public String getDbKind() {
}
public String getDialect() {
+ return dialect.get();
+ }
+
+ public Optional getDialectOptional() {
return dialect;
}
+ public Set getMatchingDialects() {
+ return matchingDialects;
+ }
+
+ public Optional getDatabaseProductName() {
+ return databaseProductName;
+ }
+
public Optional getDefaultDatabaseProductVersion() {
return defaultDatabaseProductVersion;
}
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
index 25d5e14f47844..2dffe9d53f761 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
@@ -30,8 +30,6 @@ void setupLogFilters(BuildProducer filters) {
// Silence incubating settings warnings as we will use some for compatibility
filters.produce(new LogCleanupFilterBuildItem("org.hibernate.orm.incubating",
"HHH90006001"));
- // https://hibernate.atlassian.net/browse/HHH-16546
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.tuple.entity.EntityMetamodel", "HHH000157"));
//This "deprecation" warning isn't practical for the specific Quarkus needs, as it reminds users they don't need
//to set the 'hibernate.dialect' property, however it's being set by Quarkus buildsteps so they can't avoid it.
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
index 54b5f4de5f5aa..f8533053f2012 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
@@ -162,24 +162,27 @@ public final class HibernateOrmProcessor {
@BuildStep
void registerHibernateOrmMetadataForCoreDialects(
BuildProducer producer) {
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.DB2,
- "org.hibernate.dialect.DB2Dialect"));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.DERBY,
- "org.hibernate.dialect.DerbyDialect"));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.H2,
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.DB2, "DB2",
+ Set.of("org.hibernate.dialect.DB2Dialect")));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.DERBY, "Apache Derby",
+ Set.of("org.hibernate.dialect.DerbyDialect")));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.H2, "H2",
+ Set.of("org.hibernate.dialect.H2Dialect"),
// Using our own default version is extra important for H2
// See https://github.com/quarkusio/quarkus/issues/1886
- "org.hibernate.dialect.H2Dialect", DialectVersions.Defaults.H2));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.MARIADB,
- "org.hibernate.dialect.MariaDBDialect", DialectVersions.Defaults.MARIADB));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.MSSQL,
- "org.hibernate.dialect.SQLServerDialect", DialectVersions.Defaults.MSSQL));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.MYSQL,
- "org.hibernate.dialect.MySQLDialect"));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.ORACLE,
- "org.hibernate.dialect.OracleDialect"));
- producer.produce(new DatabaseKindDialectBuildItem(DatabaseKind.POSTGRESQL,
- "org.hibernate.dialect.PostgreSQLDialect"));
+ DialectVersions.Defaults.H2));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.MARIADB, "MariaDB",
+ Set.of("org.hibernate.dialect.MariaDBDialect"),
+ DialectVersions.Defaults.MARIADB));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.MSSQL, "Microsoft SQL Server",
+ Set.of("org.hibernate.dialect.SQLServerDialect"),
+ DialectVersions.Defaults.MSSQL));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.MYSQL, "MySQL",
+ Set.of("org.hibernate.dialect.MySQLDialect")));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.ORACLE, "Oracle",
+ Set.of("org.hibernate.dialect.OracleDialect")));
+ producer.produce(DatabaseKindDialectBuildItem.forCoreDialect(DatabaseKind.POSTGRESQL, "PostgreSQL",
+ Set.of("org.hibernate.dialect.PostgreSQLDialect")));
}
@BuildStep
@@ -1107,15 +1110,18 @@ private static void collectDialectConfig(String persistenceUnitName,
}
Optional dialect = explicitDialect;
+ Optional dbProductName = Optional.empty();
Optional dbProductVersion = explicitDbMinVersion;
if (dbKind.isPresent() || explicitDialect.isPresent()) {
for (DatabaseKindDialectBuildItem item : dbKindMetadataBuildItems) {
if (dbKind.isPresent() && DatabaseKind.is(dbKind.get(), item.getDbKind())
// Set the default version based on the dialect when we don't have a datasource
// (i.e. for database multi-tenancy)
- || explicitDialect.isPresent() && explicitDialect.get().equals(item.getDialect())) {
- if (explicitDialect.isEmpty()) {
- dialect = Optional.of(item.getDialect());
+ || explicitDialect.isPresent() && item.getMatchingDialects().contains(explicitDialect.get())) {
+ dbProductName = item.getDatabaseProductName();
+ if (dbProductName.isEmpty() && explicitDialect.isEmpty()) {
+ // Use dialects only as a last resort, prefer product name or explicitly user-provided dialect
+ dialect = item.getDialectOptional();
}
if (explicitDbMinVersion.isEmpty()) {
dbProductVersion = item.getDefaultDatabaseProductVersion();
@@ -1123,7 +1129,7 @@ private static void collectDialectConfig(String persistenceUnitName,
break;
}
}
- if (dialect.isEmpty()) {
+ if (dialect.isEmpty() && dbProductName.isEmpty()) {
throw new ConfigurationException(
"The Hibernate ORM extension could not guess the dialect from the database kind '" + dbKind.get()
+ "'. Add an explicit '"
@@ -1134,6 +1140,8 @@ private static void collectDialectConfig(String persistenceUnitName,
if (dialect.isPresent()) {
puPropertiesCollector.accept(AvailableSettings.DIALECT, dialect.get());
+ } else if (dbProductName.isPresent()) {
+ puPropertiesCollector.accept(AvailableSettings.JAKARTA_HBM2DDL_DB_NAME, dbProductName.get());
} else {
// We only get here with the database multi-tenancy strategy; see the initial check, up top.
assert multiTenancyStrategy == MultiTenancyStrategy.DATABASE;
@@ -1148,7 +1156,7 @@ private static void collectDialectConfig(String persistenceUnitName,
if (persistenceUnitConfig.dialect().storageEngine().isPresent()) {
// Only actually set the storage engines if MySQL or MariaDB
- if (isMySQLOrMariaDB(dialect.get())) {
+ if (isMySQLOrMariaDB(dbKind, dialect)) {
// The storage engine has to be set as a system property.
// We record it so that we can later run checks (because we can only set a single value)
storageEngineCollector.add(persistenceUnitConfig.dialect().storageEngine().get());
@@ -1609,9 +1617,15 @@ private static Class[] toArray(final Set> interfaces) {
return interfaces.toArray(new Class[interfaces.size()]);
}
- private static boolean isMySQLOrMariaDB(String dialect) {
- String lowercaseDialect = dialect.toLowerCase(Locale.ROOT);
- return lowercaseDialect.contains("mysql") || lowercaseDialect.contains("mariadb");
+ private static boolean isMySQLOrMariaDB(Optional dbKind, Optional dialect) {
+ if (dbKind.isPresent() && (DatabaseKind.isMySQL(dbKind.get()) || DatabaseKind.isMariaDB(dbKind.get()))) {
+ return true;
+ }
+ if (dialect.isPresent()) {
+ String lowercaseDialect = dialect.get().toLowerCase(Locale.ROOT);
+ return lowercaseDialect.contains("mysql") || lowercaseDialect.contains("mariadb");
+ }
+ return false;
}
private static final class ProxyCache {
diff --git a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/Dialects.java b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/Dialects.java
deleted file mode 100644
index a699c1fabea6d..0000000000000
--- a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/Dialects.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package io.quarkus.hibernate.reactive.deployment;
-
-import java.util.List;
-
-import io.quarkus.datasource.common.runtime.DatabaseKind;
-import io.quarkus.hibernate.orm.deployment.spi.DatabaseKindDialectBuildItem;
-import io.quarkus.hibernate.orm.runtime.HibernateOrmRuntimeConfig;
-import io.quarkus.runtime.configuration.ConfigurationException;
-
-/**
- * This used to be the approach before 6bf38240 in the Hibernate ORM extension as well.
- * Align to ORM? TBD
- */
-@Deprecated
-final class Dialects {
-
- private Dialects() {
- //utility
- }
-
- public static String guessDialect(String persistenceUnitName, String resolvedDbKind,
- List dbKindDialectBuildItems) {
- for (DatabaseKindDialectBuildItem item : dbKindDialectBuildItems) {
- if (DatabaseKind.is(resolvedDbKind, item.getDbKind())) {
- return item.getDialect();
- }
- }
-
- String error = "The Hibernate ORM extension could not guess the dialect from the database kind '" + resolvedDbKind
- + "'. Add an explicit '" + HibernateOrmRuntimeConfig.puPropertyKey(persistenceUnitName, "dialect")
- + "' property.";
- throw new ConfigurationException(error);
- }
-}
diff --git a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java
index 37303a0f579a1..cd55a007cab70 100644
--- a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java
+++ b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java
@@ -427,21 +427,24 @@ private static ParsedPersistenceXmlDescriptor generateReactivePersistenceUnit(
return desc;
}
- private static void setDialectAndStorageEngine(Optional dbKindOptional, Optional explicitDialect,
+ private static void setDialectAndStorageEngine(Optional dbKind, Optional explicitDialect,
Optional explicitDbMinVersion, List dbKindDialectBuildItems,
Optional storageEngine, BuildProducer systemProperties,
ParsedPersistenceXmlDescriptor desc) {
final String persistenceUnitName = DEFAULT_PERSISTENCE_UNIT_NAME;
Optional dialect = explicitDialect;
+ Optional dbProductName = Optional.empty();
Optional dbProductVersion = explicitDbMinVersion;
- if (dbKindOptional.isPresent() || explicitDialect.isPresent()) {
+ if (dbKind.isPresent() || explicitDialect.isPresent()) {
for (DatabaseKindDialectBuildItem item : dbKindDialectBuildItems) {
- if (dbKindOptional.isPresent() && DatabaseKind.is(dbKindOptional.get(), item.getDbKind())
+ if (dbKind.isPresent() && DatabaseKind.is(dbKind.get(), item.getDbKind())
// Set the default version based on the dialect when we don't have a datasource
// (i.e. for database multi-tenancy)
- || explicitDialect.isPresent() && explicitDialect.get().equals(item.getDialect())) {
- if (explicitDialect.isEmpty()) {
- dialect = Optional.of(item.getDialect());
+ || explicitDialect.isPresent() && item.getMatchingDialects().contains(explicitDialect.get())) {
+ dbProductName = item.getDatabaseProductName();
+ if (dbProductName.isEmpty() && explicitDialect.isEmpty()) {
+ // Use dialects only as a last resort, prefer product name or explicitly user-provided dialect
+ dialect = item.getDialectOptional();
}
if (explicitDbMinVersion.isEmpty()) {
dbProductVersion = item.getDefaultDatabaseProductVersion();
@@ -449,10 +452,10 @@ private static void setDialectAndStorageEngine(Optional dbKindOptional,
break;
}
}
- if (dialect.isEmpty()) {
+ if (dialect.isEmpty() && dbProductName.isEmpty()) {
throw new ConfigurationException(
"The Hibernate Reactive extension could not guess the dialect from the database kind '"
- + dbKindOptional.get()
+ + dbKind.get()
+ "'. Add an explicit '"
+ HibernateOrmRuntimeConfig.puPropertyKey(persistenceUnitName, "dialect")
+ "' property.");
@@ -461,6 +464,8 @@ private static void setDialectAndStorageEngine(Optional dbKindOptional,
if (dialect.isPresent()) {
desc.getProperties().setProperty(AvailableSettings.DIALECT, dialect.get());
+ } else if (dbProductName.isPresent()) {
+ desc.getProperties().setProperty(AvailableSettings.JAKARTA_HBM2DDL_DB_NAME, dbProductName.get());
} else {
// We only get here with the database multi-tenancy strategy; see the initial check, up top.
throw new ConfigurationException(String.format(Locale.ROOT,
@@ -472,15 +477,11 @@ private static void setDialectAndStorageEngine(Optional dbKindOptional,
persistenceUnitName));
}
- if (dbProductVersion.isPresent()) {
- desc.getProperties().setProperty(JAKARTA_HBM2DDL_DB_VERSION, dbProductVersion.get());
- }
-
// The storage engine has to be set as a system property.
if (storageEngine.isPresent()) {
systemProperties.produce(new SystemPropertyBuildItem(STORAGE_ENGINE, storageEngine.get()));
// Only actually set the storage engines if MySQL or MariaDB
- if (isMySQLOrMariaDB(dialect.get())) {
+ if (isMySQLOrMariaDB(dbKind, dialect)) {
systemProperties.produce(new SystemPropertyBuildItem(STORAGE_ENGINE, storageEngine.get()));
} else {
LOG.warnf("The storage engine set through configuration property '%1$s' is being ignored"
@@ -489,11 +490,20 @@ private static void setDialectAndStorageEngine(Optional dbKindOptional,
}
}
+ if (dbProductVersion.isPresent()) {
+ desc.getProperties().setProperty(JAKARTA_HBM2DDL_DB_VERSION, dbProductVersion.get());
+ }
}
- private static boolean isMySQLOrMariaDB(String dialect) {
- String lowercaseDialect = dialect.toLowerCase(Locale.ROOT);
- return lowercaseDialect.contains("mysql") || lowercaseDialect.contains("mariadb");
+ private static boolean isMySQLOrMariaDB(Optional dbKind, Optional dialect) {
+ if (dbKind.isPresent() && (DatabaseKind.isMySQL(dbKind.get()) || DatabaseKind.isMariaDB(dbKind.get()))) {
+ return true;
+ }
+ if (dialect.isPresent()) {
+ String lowercaseDialect = dialect.get().toLowerCase(Locale.ROOT);
+ return lowercaseDialect.contains("mysql") || lowercaseDialect.contains("mariadb");
+ }
+ return false;
}
private static void setMaxFetchDepth(ParsedPersistenceXmlDescriptor descriptor, OptionalInt maxFetchDepth) {