2020import org .hibernate .PessimisticLockException ;
2121import org .hibernate .boot .model .FunctionContributions ;
2222import org .hibernate .boot .model .TypeContributions ;
23+ import org .hibernate .cfg .AvailableSettings ;
2324import org .hibernate .cfg .Environment ;
25+ import org .hibernate .cfg .FetchSettings ;
2426import org .hibernate .dialect .aggregate .AggregateSupport ;
2527import org .hibernate .dialect .aggregate .MySQLAggregateSupport ;
2628import org .hibernate .dialect .function .CommonFunctionFactory ;
8991import static org .hibernate .exception .spi .TemplatedViolatedConstraintNameExtractor .extractUsingTemplate ;
9092import static org .hibernate .internal .util .JdbcExceptionHelper .extractSqlState ;
9193import static org .hibernate .internal .util .StringHelper .isNotEmpty ;
94+ import static org .hibernate .internal .util .StringHelper .split ;
9295import static org .hibernate .type .SqlTypes .BIGINT ;
9396import static org .hibernate .type .SqlTypes .BINARY ;
9497import static org .hibernate .type .SqlTypes .BIT ;
@@ -217,7 +220,7 @@ protected static DatabaseVersion createVersion(DialectResolutionInfo info) {
217220 protected static DatabaseVersion createVersion (DialectResolutionInfo info , DatabaseVersion defaultVersion ) {
218221 final String versionString = info .getDatabaseVersion ();
219222 if ( versionString != null ) {
220- final String [] components = StringHelper . split ( ".-" , versionString );
223+ final String [] components = split ( ".-" , versionString );
221224 if ( components .length >= 3 ) {
222225 try {
223226 final int majorVersion = parseInt ( components [0 ] );
@@ -241,26 +244,19 @@ protected DatabaseVersion getMinimumSupportedVersion() {
241244 @ Override
242245 protected void initDefaultProperties () {
243246 super .initDefaultProperties ();
244- getDefaultProperties ().setProperty ( Environment .MAX_FETCH_DEPTH , "2" );
247+ getDefaultProperties ().setProperty ( FetchSettings .MAX_FETCH_DEPTH , "2" );
245248 }
246249
247250 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+ };
264260 }
265261
266262 @ Override
0 commit comments