Skip to content

Commit baaf91a

Browse files
committed
Rebase of quarkusio#43396
* Offline test running (except for MY_CUSTOM_ENGINE)
1 parent bd9943f commit baaf91a

File tree

17 files changed

+632
-17
lines changed

17 files changed

+632
-17
lines changed

docs/src/main/asciidoc/_attributes.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
:quickstarts-tree-url: ${quickstarts-base-url}/tree/main
5555
// .
5656
:hibernate-orm-docs-url: https://docs.jboss.org/hibernate/orm/{hibernate-orm-version-major-minor}/userguide/html_single/Hibernate_User_Guide.html
57+
:hibernate-orm-javadocs-url: https://docs.jboss.org/hibernate/orm/{hibernate-orm-version-major-minor}/javadocs/
5758
:hibernate-orm-dialect-docs-url: https://docs.jboss.org/hibernate/orm/{hibernate-orm-version-major-minor}/dialect/dialect.html
5859
:hibernate-search-docs-url: https://docs.jboss.org/hibernate/search/{hibernate-search-version-major-minor}/reference/en-US/html_single/
5960
:hibernate-validator-docs-url: https://docs.jboss.org/hibernate/validator/{hibernate-validator-version-major-minor}/reference/en-US/html_single/

extensions/datasource/common/src/main/java/io/quarkus/datasource/common/runtime/DatabaseKind.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public static boolean is(String value, String mainName) {
9797
private DatabaseKind() {
9898
}
9999

100-
private enum SupportedDatabaseKind {
100+
public enum SupportedDatabaseKind {
101101
DB2(DatabaseKind.DB2),
102102
DERBY(DatabaseKind.DERBY),
103103
H2(DatabaseKind.H2),
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigGroup;
6+
import io.quarkus.runtime.configuration.TrimmedStringConverter;
7+
import io.smallrye.config.WithConverter;
8+
9+
/**
10+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.CockroachDialect}
11+
*
12+
* @author Steve Ebersole
13+
*/
14+
@ConfigGroup
15+
public interface CockroachDialectConfig {
16+
/**
17+
* Specialized version string which can be passed into the {@linkplain org.hibernate.dialect.CockroachDialect}
18+
*/
19+
@WithConverter(TrimmedStringConverter.class)
20+
Optional<String> versionString();
21+
22+
default boolean isAnyPropertySet() {
23+
return versionString().isPresent();
24+
}
25+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigDocDefault;
6+
import io.quarkus.runtime.annotations.ConfigGroup;
7+
8+
/**
9+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.HANADialect}
10+
*
11+
* @author Steve Ebersole
12+
*/
13+
@ConfigGroup
14+
public interface HANADialectConfig {
15+
/**
16+
* Specifies the LOB prefetch size.
17+
*
18+
* @see org.hibernate.cfg.DialectSpecificSettings#HANA_MAX_LOB_PREFETCH_SIZE
19+
*/
20+
@ConfigDocDefault("1024")
21+
Optional<Integer> maxLobPrefetchSize();
22+
23+
default boolean isAnyPropertySet() {
24+
return maxLobPrefetchSize().isPresent();
25+
}
26+
}

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,41 @@ interface HibernateOrmConfigPersistenceUnitDialect {
304304
*
305305
* E.g. `MyISAM` or `InnoDB` for MySQL.
306306
*
307+
* @deprecated Use {@code mysql.}{@linkplain MySQLDialectConfig#storageEngine storage-engine}
308+
* or {@code mariadb.}{@linkplain MySQLDialectConfig#storageEngine storage-engine} instead
309+
*
307310
* @asciidoclet
308311
*/
309-
Optional<@WithConverter(TrimmedStringConverter.class) String> storageEngine();
312+
@WithConverter(TrimmedStringConverter.class)
313+
@Deprecated
314+
Optional<String> storageEngine();
315+
316+
/**
317+
* Configuration specific to Hibernate's Dialect for MariaDB
318+
*/
319+
MySQLDialectConfig mariadb();
320+
321+
/**
322+
* Configuration specific to Hibernate's Dialect for MySQL
323+
*/
324+
MySQLDialectConfig mysql();
325+
326+
/**
327+
* Configuration specific to Hibernate's Dialect for Oracle
328+
*/
329+
OracleDialectConfig oracle();
330+
331+
/**
332+
* Configuration specific to Hibernate's Dialect for Microsoft SQLServer
333+
*/
334+
SqlServerDialectConfig mssql();
310335

311336
default boolean isAnyPropertySet() {
312-
return dialect().isPresent() || storageEngine().isPresent();
337+
return dialect().isPresent() || storageEngine().isPresent()
338+
|| mysql().isAnyPropertySet()
339+
|| oracle().isAnyPropertySet()
340+
|| mssql().isAnyPropertySet()
341+
|| mariadb().isAnyPropertySet();
313342
}
314343
}
315344

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,10 @@ private static void collectDialectConfig(String persistenceUnitName,
994994
BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods,
995995
BiConsumer<String, String> puPropertiesCollector,
996996
Set<String> storageEngineCollector) {
997-
Optional<String> dialect = persistenceUnitConfig.dialect().dialect();
997+
final HibernateOrmConfigPersistenceUnit.HibernateOrmConfigPersistenceUnitDialect dialectConfig = persistenceUnitConfig
998+
.dialect();
999+
1000+
Optional<String> dialect = dialectConfig.dialect();
9981001
Optional<String> dbKind = jdbcDataSource.map(JdbcDataSourceBuildItem::getDbKind);
9991002
Optional<String> explicitDbMinVersion = jdbcDataSource.flatMap(JdbcDataSourceBuildItem::getDbVersion);
10001003
if (multiTenancyStrategy != MultiTenancyStrategy.DATABASE && jdbcDataSource.isEmpty()) {
@@ -1012,6 +1015,7 @@ private static void collectDialectConfig(String persistenceUnitName,
10121015
dbKind,
10131016
dialect,
10141017
explicitDbMinVersion,
1018+
dialectConfig,
10151019
dbKindMetadataBuildItems,
10161020
persistenceUnitConfig.dialect().storageEngine(),
10171021
systemProperties,
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigDocDefault;
6+
import io.quarkus.runtime.annotations.ConfigGroup;
7+
import io.quarkus.runtime.configuration.TrimmedStringConverter;
8+
import io.smallrye.config.WithConverter;
9+
10+
/**
11+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.MySQLDialect},
12+
* though may also affect other dialects such as {@linkplain org.hibernate.dialect.MariaDBDialect}.
13+
*
14+
* @author Steve Ebersole
15+
*/
16+
@ConfigGroup
17+
public interface MySQLDialectConfig {
18+
/**
19+
* Specifies the bytes per character to use based on the database's configured
20+
* <a href="https://dev.mysql.com/doc/refman/8.0/en/charset-charsets.html">charset</a>.
21+
*
22+
* @see org.hibernate.cfg.DialectSpecificSettings#MYSQL_BYTES_PER_CHARACTER
23+
*/
24+
@ConfigDocDefault("4")
25+
Optional<Integer> bytesPerCharacter();
26+
27+
/**
28+
* Specifies whether the {@code NO_BACKSLASH_ESCAPES} sql mode is enabled.
29+
*
30+
* @see org.hibernate.cfg.DialectSpecificSettings#MYSQL_NO_BACKSLASH_ESCAPES
31+
*/
32+
@ConfigDocDefault("false")
33+
Optional<Boolean> noBackslashEscapes();
34+
35+
/**
36+
* The storage engine to use.
37+
*/
38+
@WithConverter(TrimmedStringConverter.class)
39+
Optional<String> storageEngine();
40+
41+
default boolean isAnyPropertySet() {
42+
return bytesPerCharacter().isPresent()
43+
|| noBackslashEscapes().isPresent()
44+
|| storageEngine().isPresent();
45+
}
46+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigDocDefault;
6+
import io.quarkus.runtime.annotations.ConfigGroup;
7+
8+
/**
9+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.OracleDialect}
10+
*
11+
* @author Steve Ebersole
12+
*/
13+
@ConfigGroup
14+
public interface OracleDialectConfig {
15+
16+
/**
17+
* Support for Oracle's MAX_STRING_SIZE = EXTENDED.
18+
*
19+
* @see org.hibernate.cfg.DialectSpecificSettings#ORACLE_EXTENDED_STRING_SIZE
20+
*/
21+
@ConfigDocDefault("false")
22+
Optional<Boolean> extended();
23+
24+
/**
25+
* Specifies whether this database is running on an Autonomous Database Cloud Service.
26+
*
27+
* @see org.hibernate.cfg.DialectSpecificSettings#ORACLE_AUTONOMOUS_DATABASE
28+
*/
29+
@ConfigDocDefault("false")
30+
Optional<Boolean> autonomous();
31+
32+
/**
33+
* Specifies whether this database is accessed using a database service protected by Application Continuity.
34+
*
35+
* @see org.hibernate.cfg.DialectSpecificSettings#ORACLE_APPLICATION_CONTINUITY
36+
*/
37+
@ConfigDocDefault("false")
38+
Optional<Boolean> applicationContinuity();
39+
40+
default boolean isAnyPropertySet() {
41+
return extended().isPresent()
42+
|| autonomous().isPresent()
43+
|| applicationContinuity().isPresent();
44+
}
45+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigGroup;
6+
import io.quarkus.runtime.configuration.TrimmedStringConverter;
7+
import io.smallrye.config.WithConverter;
8+
9+
/**
10+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.SQLServerDialect}
11+
*
12+
* @author Steve Ebersole
13+
*/
14+
@ConfigGroup
15+
public interface SqlServerDialectConfig {
16+
/**
17+
* The {@code compatibility_level} as defined in {@code sys.databases}.
18+
*
19+
* @see org.hibernate.cfg.DialectSpecificSettings#SQL_SERVER_COMPATIBILITY_LEVEL
20+
*/
21+
@WithConverter(TrimmedStringConverter.class)
22+
Optional<String> compatibilityLevel();
23+
24+
default boolean isAnyPropertySet() {
25+
return compatibilityLevel().isPresent();
26+
}
27+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.quarkus.hibernate.orm.deployment;
2+
3+
import java.util.Optional;
4+
5+
import io.quarkus.runtime.annotations.ConfigDocDefault;
6+
import io.quarkus.runtime.annotations.ConfigGroup;
7+
8+
/**
9+
* Configuration specific to the Hibernate ORM {@linkplain org.hibernate.dialect.SybaseDialect}
10+
*
11+
* @author Steve Ebersole
12+
*/
13+
@ConfigGroup
14+
public interface SybaseDialectConfig {
15+
16+
/**
17+
* Whether the database's {@code ansinull} setting is enabled
18+
*
19+
* @see org.hibernate.cfg.DialectSpecificSettings#SYBASE_ANSI_NULL
20+
*/
21+
@SuppressWarnings("SpellCheckingInspection")
22+
@ConfigDocDefault("false")
23+
Optional<Boolean> ansinull();
24+
25+
default boolean isAnyPropertySet() {
26+
return ansinull().isPresent();
27+
}
28+
}

0 commit comments

Comments
 (0)