20
20
import org .hibernate .PessimisticLockException ;
21
21
import org .hibernate .boot .model .FunctionContributions ;
22
22
import org .hibernate .boot .model .TypeContributions ;
23
+ import org .hibernate .cfg .AvailableSettings ;
23
24
import org .hibernate .cfg .Environment ;
25
+ import org .hibernate .cfg .FetchSettings ;
24
26
import org .hibernate .dialect .aggregate .AggregateSupport ;
25
27
import org .hibernate .dialect .aggregate .MySQLAggregateSupport ;
26
28
import org .hibernate .dialect .function .CommonFunctionFactory ;
89
91
import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
90
92
import static org .hibernate .internal .util .JdbcExceptionHelper .extractSqlState ;
91
93
import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
94
+ import static org .hibernate .internal .util .StringHelper .split ;
92
95
import static org .hibernate .type .SqlTypes .BIGINT ;
93
96
import static org .hibernate .type .SqlTypes .BINARY ;
94
97
import static org .hibernate .type .SqlTypes .BIT ;
@@ -217,7 +220,7 @@ protected static DatabaseVersion createVersion(DialectResolutionInfo info) {
217
220
protected static DatabaseVersion createVersion (DialectResolutionInfo info , DatabaseVersion defaultVersion ) {
218
221
final String versionString = info .getDatabaseVersion ();
219
222
if ( versionString != null ) {
220
- final String [] components = StringHelper . split ( ".-" , versionString );
223
+ final String [] components = split ( ".-" , versionString );
221
224
if ( components .length >= 3 ) {
222
225
try {
223
226
final int majorVersion = parseInt ( components [0 ] );
@@ -241,26 +244,19 @@ protected DatabaseVersion getMinimumSupportedVersion() {
241
244
@ Override
242
245
protected void initDefaultProperties () {
243
246
super .initDefaultProperties ();
244
- getDefaultProperties ().setProperty ( Environment .MAX_FETCH_DEPTH , "2" );
247
+ getDefaultProperties ().setProperty ( FetchSettings .MAX_FETCH_DEPTH , "2" );
245
248
}
246
249
247
250
private MySQLStorageEngine createStorageEngine () {
248
- String storageEngine = Environment .getProperties ().getProperty ( Environment .STORAGE_ENGINE );
249
- if (storageEngine == null ) {
250
- storageEngine = System .getProperty ( Environment .STORAGE_ENGINE );
251
- }
252
- if (storageEngine == null ) {
253
- return getDefaultMySQLStorageEngine ();
254
- }
255
- else if ( "innodb" .equalsIgnoreCase ( storageEngine ) ) {
256
- return InnoDBStorageEngine .INSTANCE ;
257
- }
258
- else if ( "myisam" .equalsIgnoreCase ( storageEngine ) ) {
259
- return MyISAMStorageEngine .INSTANCE ;
260
- }
261
- else {
262
- throw new UnsupportedOperationException ( "The " + storageEngine + " storage engine is not supported" );
263
- }
251
+ final String storageEngine = Environment .getProperties ().getProperty ( AvailableSettings .STORAGE_ENGINE );
252
+ return storageEngine == null
253
+ ? getDefaultMySQLStorageEngine ()
254
+ : switch ( storageEngine ) {
255
+ case "innodb" -> InnoDBStorageEngine .INSTANCE ;
256
+ case "myisam" -> MyISAMStorageEngine .INSTANCE ;
257
+ default -> throw new UnsupportedOperationException (
258
+ "The '" + storageEngine + "' storage engine is not supported" );
259
+ };
264
260
}
265
261
266
262
@ Override
0 commit comments