diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java index 3f28eb4453..fdade45ab2 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java @@ -46,6 +46,7 @@ import org.hibernate.type.StandardBasicTypes; public class MySQLDialect extends Dialect { private final UniqueDelegate uniqueDelegate; + private MySQLStorageEngine storageEngine; private static final LimitHandler LIMIT_HANDLER = new AbstractLimitHandler() { @Override @@ -65,6 +66,24 @@ public class MySQLDialect extends Dialect { */ public MySQLDialect() { super(); + + String storageEngine = Environment.getProperties().getProperty( Environment.STORAGE_ENGINE ); + if(storageEngine == null) { + storageEngine = System.getProperty( Environment.STORAGE_ENGINE ); + } + if(storageEngine == null) { + this.storageEngine = getDefaultMySQLStorageEngine(); + } + else if( "innodb".equals( storageEngine.toLowerCase() ) ) { + this.storageEngine = InnoDBStorageEngine.INSTANCE; + } + else if( "myisam".equals( storageEngine.toLowerCase() ) ) { + this.storageEngine = MyISAMStorageEngine.INSTANCE; + } + else { + throw new UnsupportedOperationException( "The " + storageEngine + " storage engine is not supported!" ); + } + registerColumnType( Types.BIT, "bit" ); registerColumnType( Types.BIGINT, "bigint" ); registerColumnType( Types.SMALLINT, "smallint" ); @@ -539,12 +558,12 @@ public class MySQLDialect extends Dialect { @Override public boolean supportsCascadeDelete() { - return getMySQLStorageEngine().supportsCascadeDelete(); + return storageEngine.supportsCascadeDelete(); } @Override public String getTableTypeString() { - return getMySQLStorageEngine().getTableTypeString(getEngineKeyword()); + return storageEngine.getTableTypeString( getEngineKeyword()); } protected String getEngineKeyword() { @@ -553,31 +572,12 @@ public class MySQLDialect extends Dialect { @Override public boolean hasSelfReferentialForeignKeyBug() { - return getMySQLStorageEngine().hasSelfReferentialForeignKeyBug(); + return storageEngine.hasSelfReferentialForeignKeyBug(); } @Override public boolean dropConstraints() { - return getMySQLStorageEngine().dropConstraints(); - } - - protected MySQLStorageEngine getMySQLStorageEngine() { - String storageEngine = Environment.getProperties().getProperty( Environment.STORAGE_ENGINE ); - if(storageEngine == null) { - storageEngine = System.getProperty( Environment.STORAGE_ENGINE ); - } - if(storageEngine == null) { - return getDefaultMySQLStorageEngine(); - } - if( "innodb".equals( storageEngine.toLowerCase() ) ) { - return InnoDBStorageEngine.INSTANCE; - } - else if( "myisam".equals( storageEngine.toLowerCase() ) ) { - return MyISAMStorageEngine.INSTANCE; - } - else { - throw new UnsupportedOperationException( "The " + storageEngine + " storage engine is not supported!" ); - } + return storageEngine.dropConstraints(); } protected MySQLStorageEngine getDefaultMySQLStorageEngine() {