|
26 | 26 | import jakarta.persistence.ValidationMode;
|
27 | 27 |
|
28 | 28 | import org.hibernate.cfg.AvailableSettings;
|
29 |
| -import org.hibernate.community.dialect.CommunityDatabase; |
30 |
| -import org.hibernate.dialect.Database; |
31 | 29 | import org.hibernate.id.SequenceMismatchStrategy;
|
32 | 30 | import org.hibernate.jpa.boot.spi.JpaSettings;
|
33 | 31 | import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
|
@@ -114,6 +112,9 @@ public static Optional<SupportedDatabaseKind> setDialectAndStorageEngine(
|
114 | 112 | for (DatabaseKindDialectBuildItem item : dbKindDialectBuildItems) {
|
115 | 113 | if (dbKind.isPresent() && DatabaseKind.is(dbKind.get(), item.getDbKind())
|
116 | 114 | || explicitDialect.isPresent() && item.getMatchingDialects().contains(explicitDialect.get())) {
|
| 115 | + if (dbKind.isEmpty()) { |
| 116 | + dbKind = Optional.ofNullable(item.getDbKind()); |
| 117 | + } |
117 | 118 | dbProductName = item.getDatabaseProductName();
|
118 | 119 | if (dbProductName.isEmpty() && explicitDialect.isEmpty()) {
|
119 | 120 | dialect = item.getDialectOptional();
|
@@ -145,9 +146,6 @@ public static Optional<SupportedDatabaseKind> setDialectAndStorageEngine(
|
145 | 146 | }
|
146 | 147 |
|
147 | 148 | Optional<SupportedDatabaseKind> supportedDbKind = dbKind.flatMap(SupportedDatabaseKind::from);
|
148 |
| - if (supportedDbKind.isEmpty()) { |
149 |
| - supportedDbKind = supportedDatabaseKindFromProductName(dbProductName); |
150 |
| - } |
151 | 149 |
|
152 | 150 | handleDialectSpecificSettings(
|
153 | 151 | persistenceUnitName,
|
@@ -216,42 +214,6 @@ private static void handleDialectSpecificSettings(
|
216 | 214 | }
|
217 | 215 | }
|
218 | 216 |
|
219 |
| - private static Optional<SupportedDatabaseKind> supportedDatabaseKindFromProductName( |
220 |
| - Optional<String> dbProductNameOptional) { |
221 |
| - |
222 |
| - return dbProductNameOptional |
223 |
| - .filter(s -> !s.isEmpty()) |
224 |
| - .flatMap(dbProductName -> { |
225 |
| - |
226 |
| - if (Database.DB2.productNameMatches(dbProductName)) { |
227 |
| - return Optional.of(SupportedDatabaseKind.DB2); |
228 |
| - } |
229 |
| - if (CommunityDatabase.DERBY.productNameMatches(dbProductName)) { |
230 |
| - return Optional.of(SupportedDatabaseKind.DERBY); |
231 |
| - } |
232 |
| - if (Database.H2.productNameMatches(dbProductName)) { |
233 |
| - return Optional.of(SupportedDatabaseKind.H2); |
234 |
| - } |
235 |
| - if (Database.MARIADB.productNameMatches(dbProductName)) { |
236 |
| - return Optional.of(SupportedDatabaseKind.MARIADB); |
237 |
| - } |
238 |
| - if (Database.MYSQL.productNameMatches(dbProductName)) { |
239 |
| - return Optional.of(SupportedDatabaseKind.MYSQL); |
240 |
| - } |
241 |
| - if (Database.ORACLE.productNameMatches(dbProductName)) { |
242 |
| - return Optional.of(SupportedDatabaseKind.ORACLE); |
243 |
| - } |
244 |
| - if (Database.POSTGRESQL.productNameMatches(dbProductName)) { |
245 |
| - return Optional.of(SupportedDatabaseKind.POSTGRESQL); |
246 |
| - } |
247 |
| - if (Database.SQLSERVER.productNameMatches(dbProductName)) { |
248 |
| - return Optional.of(SupportedDatabaseKind.MSSQL); |
249 |
| - } |
250 |
| - return Optional.empty(); |
251 |
| - |
252 |
| - }); |
253 |
| - } |
254 |
| - |
255 | 217 | private static void handleStorageEngine(
|
256 | 218 | Optional<SupportedDatabaseKind> supportedDatabaseKind,
|
257 | 219 | String persistenceUnitName,
|
|
0 commit comments