HHH-11473 - Refactor MySQL Dialects
This commit is contained in:
parent
d82b3369ff
commit
2b79644b63
|
@ -38,7 +38,7 @@ ext {
|
|||
'jdbc.url' : 'jdbc:postgresql:hibernate_orm_test'
|
||||
],
|
||||
mysql : [
|
||||
'db.dialect' : 'org.hibernate.dialect.MySQL57InnoDBDialect',
|
||||
'db.dialect' : 'org.hibernate.dialect.MySQL57Dialect',
|
||||
'jdbc.driver': 'com.mysql.jdbc.Driver',
|
||||
'jdbc.user' : 'hibernateormtest',
|
||||
'jdbc.pass' : 'hibernateormtest',
|
||||
|
|
|
@ -137,12 +137,8 @@ There are several dialects for MySQL:
|
|||
|
||||
`MySQLSpatialDialect`:::
|
||||
a spatially-extended version of Hibernate `MySQLDialect`
|
||||
`MySQLSpatialInnoDBDialect`:::
|
||||
a spatially-extended version of Hibernate `MySQLInnoDBDialect`
|
||||
`MySQLSpatial56Dialect`:::
|
||||
a spatially-extended version of Hibernate `MySQL5DBDialect`.
|
||||
`MySQLSpatial5InnoDBDialect`:::
|
||||
the same as `MySQLSpatial56Dialect`, but with support for the InnoDB storage engine.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
|
@ -150,7 +146,7 @@ MySQL versions before 5.6.1 had only limited support for spatial operators.
|
|||
Most operators only took account of the minimum bounding rectangles (MBR) of the geometries, and not the geometries themselves.
|
||||
|
||||
This changed in version 5.6.1 were MySQL introduced `ST_*` spatial operators.
|
||||
The dialects `MySQLSpatial56Dialect` and `MySQLSpatial5InnoDBDialect` use these newer, more precise operators.
|
||||
The dialect `MySQLSpatial56Dialect` uses these newer, more precise operators.
|
||||
|
||||
These dialects may therefore produce results that differ from that of the other spatial dialects.
|
||||
|
||||
|
|
|
@ -43,8 +43,6 @@ hibernate.connection.url @DB_URL@
|
|||
|
||||
|
||||
#hibernate.dialect org.hibernate.dialect.MySQLDialect
|
||||
#hibernate.dialect org.hibernate.dialect.MySQLInnoDBDialect
|
||||
#hibernate.dialect org.hibernate.dialect.MySQLMyISAMDialect
|
||||
#hibernate.connection.driver_class org.gjt.mm.mysql.Driver
|
||||
#hibernate.connection.driver_class com.mysql.jdbc.Driver
|
||||
#hibernate.connection.url jdbc:mysql:///test
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.hibernate.dialect.InterbaseDialect;
|
|||
import org.hibernate.dialect.JDataStoreDialect;
|
||||
import org.hibernate.dialect.MckoiDialect;
|
||||
import org.hibernate.dialect.MimerSQLDialect;
|
||||
import org.hibernate.dialect.MySQL57Dialect;
|
||||
import org.hibernate.dialect.MySQL57InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||
|
@ -212,6 +213,7 @@ public class StrategySelectorBuilder {
|
|||
addDialect( strategySelector, MySQL5Dialect.class );
|
||||
addDialect( strategySelector, MySQL5InnoDBDialect.class );
|
||||
addDialect( strategySelector, MySQL57InnoDBDialect.class );
|
||||
addDialect( strategySelector, MySQL57Dialect.class );
|
||||
addDialect( strategySelector, Oracle8iDialect.class );
|
||||
addDialect( strategySelector, Oracle9iDialect.class );
|
||||
addDialect( strategySelector, Oracle10gDialect.class );
|
||||
|
|
|
@ -379,6 +379,15 @@ public interface AvailableSettings {
|
|||
*/
|
||||
String DIALECT_RESOLVERS = "hibernate.dialect_resolvers";
|
||||
|
||||
/**
|
||||
* Defines the default storage engine for the relational databases that support multiple storage engines.
|
||||
* This property must be set either as an Environment variable or JVM System Property.
|
||||
* That is because the Dialect is bootstrapped prior to Hibernate property resolution.
|
||||
*
|
||||
* @since 5.2.9
|
||||
*/
|
||||
String STORAGE_ENGINE = "hibernate.dialect.storage_engine";
|
||||
|
||||
/**
|
||||
* Used to specify the {@link org.hibernate.tool.schema.spi.SchemaManagementTool} to use for performing
|
||||
* schema management. The default is to use {@link org.hibernate.tool.schema.internal.HibernateSchemaManagementTool}
|
||||
|
|
|
@ -256,7 +256,6 @@ public abstract class Dialect implements ConversionContext {
|
|||
return instantiateDialect( Environment.getProperties().getProperty( Environment.DIALECT ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get an instance of the dialect specified by the given properties or by
|
||||
* the current <tt>System</tt> properties.
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.hibernate.dialect;
|
||||
|
||||
/**
|
||||
* Represents the InnoDB storage engine.
|
||||
*
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class InnoDBStorageEngine implements MySQLStorageEngine{
|
||||
|
||||
public static final MySQLStorageEngine INSTANCE = new InnoDBStorageEngine();
|
||||
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableTypeString(String engineKeyword) {
|
||||
return String.format( " %s=InnoDB", engineKeyword );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSelfReferentialForeignKeyBug() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dropConstraints() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ package org.hibernate.dialect;
|
|||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class MariaDBDialect extends MySQL5InnoDBDialect {
|
||||
public class MariaDBDialect extends MySQL5Dialect {
|
||||
public MariaDBDialect() {
|
||||
super();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
package org.hibernate.dialect;
|
||||
|
||||
/**
|
||||
* Represents the MyISAM storage engine.
|
||||
*
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class MyISAMStorageEngine implements MySQLStorageEngine{
|
||||
|
||||
public static final MySQLStorageEngine INSTANCE = new MyISAMStorageEngine();
|
||||
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableTypeString(String engineKeyword) {
|
||||
return String.format( " %s=MyISAM", engineKeyword );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSelfReferentialForeignKeyBug() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dropConstraints() {
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
/**
|
||||
* An SQL dialect for MySQL 5.5.x specific features.
|
||||
*
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class MySQL55Dialect extends MySQL5Dialect {
|
||||
|
||||
@Override
|
||||
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
||||
return InnoDBStorageEngine.INSTANCE;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.dialect.function.StaticPrecisionFspTimestampFunction;
|
||||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class MySQL57Dialect extends MySQL55Dialect {
|
||||
public MySQL57Dialect() {
|
||||
super();
|
||||
|
||||
// For details about MySQL 5.7 support for fractional seconds
|
||||
// precision (fsp): http://dev.mysql.com/doc/refman/5.7/en/fractional-seconds.html
|
||||
// Regarding datetime(fsp), "The fsp value, if given, must be
|
||||
// in the range 0 to 6. A value of 0 signifies that there is
|
||||
// no fractional part. If omitted, the default precision is 0.
|
||||
// (This differs from the standard SQL default of 6, for
|
||||
// compatibility with previous MySQL versions.)".
|
||||
|
||||
// The following is defined because Hibernate currently expects
|
||||
// the SQL 1992 default of 6 (which is inconsistent with the MySQL
|
||||
// default).
|
||||
registerColumnType( Types.TIMESTAMP, "datetime(6)" );
|
||||
|
||||
// MySQL 5.7 brings JSON native support with a dedicated datatype.
|
||||
// For more details about MySql new JSON datatype support, see:
|
||||
// https://dev.mysql.com/doc/refman/5.7/en/json.html
|
||||
registerColumnType( Types.JAVA_OBJECT, "json" );
|
||||
|
||||
// MySQL also supports fractional seconds precision for time values
|
||||
// (time(fsp)). According to SQL 1992, the default for <time precision>
|
||||
// is 0. The MySQL default is time(0), there's no need to override
|
||||
// the setting for Types.TIME columns.
|
||||
|
||||
// For details about MySQL support for timestamp functions, see:
|
||||
// http://dev.mysql.com/doc/refman/5.7/en/date-and-time-functions.html
|
||||
|
||||
// The following are synonyms for now(fsp), where fsp defaults to 0 on MySQL 5.7:
|
||||
// current_timestamp([fsp]), localtime(fsp), localtimestamp(fsp).
|
||||
// Register the same StaticPrecisionFspTimestampFunction for all 4 functions.
|
||||
final SQLFunction currentTimestampFunction = new StaticPrecisionFspTimestampFunction("now", 6 );
|
||||
|
||||
registerFunction( "now", currentTimestampFunction );
|
||||
registerFunction( "current_timestamp", currentTimestampFunction );
|
||||
registerFunction( "localtime", currentTimestampFunction );
|
||||
registerFunction( "localtimestamp", currentTimestampFunction );
|
||||
|
||||
// sysdate is different from now():
|
||||
// "SYSDATE() returns the time at which it executes. This differs
|
||||
// from the behavior for NOW(), which returns a constant time that
|
||||
// indicates the time at which the statement began to execute.
|
||||
// (Within a stored function or trigger, NOW() returns the time at
|
||||
// which the function or triggering statement began to execute.)
|
||||
registerFunction( "sysdate", new StaticPrecisionFspTimestampFunction( "sysdate", 6 ) );
|
||||
|
||||
// from_unixtime(), timestamp() are functions that return TIMESTAMP that do not support a
|
||||
// fractional seconds precision argument (so there's no need to override them here):
|
||||
}
|
||||
|
||||
/**
|
||||
* @see <a href="https://dev.mysql.com/worklog/task/?id=7019">MySQL 5.7 work log</a>
|
||||
* @return supports IN clause row value expressions
|
||||
*/
|
||||
public boolean supportsRowValueConstructorSyntaxInInList() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -13,7 +13,9 @@ import org.hibernate.dialect.function.StaticPrecisionFspTimestampFunction;
|
|||
|
||||
/**
|
||||
* @author Gail Badner
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQL57InnoDBDialect extends MySQL5InnoDBDialect {
|
||||
public MySQL57InnoDBDialect() {
|
||||
super();
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter;
|
||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtracter;
|
||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Types;
|
||||
|
||||
/**
|
||||
* An SQL dialect for MySQL 5.x specific features.
|
||||
*
|
||||
|
@ -36,6 +36,10 @@ public class MySQL5Dialect extends MySQLDialect {
|
|||
return EXTRACTER;
|
||||
}
|
||||
|
||||
protected String getEngineKeyword() {
|
||||
return "engine";
|
||||
}
|
||||
|
||||
private static final ViolatedConstraintNameExtracter EXTRACTER = new TemplatedViolatedConstraintNameExtracter() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,7 +10,9 @@ package org.hibernate.dialect;
|
|||
*
|
||||
* @author Gavin King,
|
||||
* @author Scott Marlow
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQL5InnoDBDialect extends MySQL5Dialect {
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
|
|
|
@ -310,11 +310,6 @@ public class MySQLDialect extends Dialect {
|
|||
return "select uuid()";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableComment(String comment) {
|
||||
return " comment='" + comment + "'";
|
||||
|
@ -541,4 +536,51 @@ public class MySQLDialect extends Dialect {
|
|||
public boolean isJdbcLogWarningsEnabledByDefault() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
return getMySQLStorageEngine().supportsCascadeDelete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableTypeString() {
|
||||
return getMySQLStorageEngine().getTableTypeString(getEngineKeyword());
|
||||
}
|
||||
|
||||
protected String getEngineKeyword() {
|
||||
return "type";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSelfReferentialForeignKeyBug() {
|
||||
return getMySQLStorageEngine().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!" );
|
||||
}
|
||||
}
|
||||
|
||||
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
||||
return MyISAMStorageEngine.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ package org.hibernate.dialect;
|
|||
* A Dialect for MySQL using InnoDB engine
|
||||
*
|
||||
* @author Gavin King
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQLInnoDBDialect extends MySQLDialect {
|
||||
@Override
|
||||
public boolean supportsCascadeDelete() {
|
||||
|
|
|
@ -10,7 +10,9 @@ package org.hibernate.dialect;
|
|||
* A Dialect for MySQL using the MyISAM engine
|
||||
*
|
||||
* @author Gavin King
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=myisam" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQLMyISAMDialect extends MySQLDialect {
|
||||
@Override
|
||||
public String getTableTypeString() {
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.hibernate.dialect;
|
||||
|
||||
/**
|
||||
* This interface defines how various MySQL storage engines behave in regard to Hibernate functionality.
|
||||
*
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public interface MySQLStorageEngine {
|
||||
|
||||
boolean supportsCascadeDelete();
|
||||
|
||||
String getTableTypeString(String engineKeyword);
|
||||
|
||||
boolean hasSelfReferentialForeignKeyBug();
|
||||
|
||||
boolean dropConstraints();
|
||||
}
|
|
@ -6,23 +6,25 @@
|
|||
*/
|
||||
package org.hibernate.test.annotations;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.EnumSet;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.boot.MetadataBuilder;
|
||||
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
|
||||
import org.hibernate.dialect.Oracle10gDialect;
|
||||
import org.hibernate.query.Query;
|
||||
import org.hibernate.tool.hbm2ddl.SchemaExport;
|
||||
import org.hibernate.tool.schema.TargetType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
|
@ -33,6 +35,7 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hibernate.testing.transaction.TransactionUtil.doInHibernate;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -365,36 +368,38 @@ public class EntityTest extends BaseNonConfigCoreFunctionalTestCase {
|
|||
@Test
|
||||
@SkipForDialect(value = Oracle10gDialect.class, comment = "oracle12c returns time in getDate. For now, skip.")
|
||||
public void testTemporalType() throws Exception {
|
||||
Session s = openSession();
|
||||
Transaction tx = s.beginTransaction();
|
||||
Flight airFrance = new Flight();
|
||||
airFrance.setId( Long.valueOf( 747 ) );
|
||||
airFrance.setName( "Paris-Amsterdam" );
|
||||
airFrance.setDuration( Long.valueOf( 10 ) );
|
||||
airFrance.setDepartureDate( new Date( 05, 06, 21, 10, 0, 0 ) );
|
||||
airFrance.setAlternativeDepartureDate( new GregorianCalendar( 2006, 02, 03, 10, 00 ) );
|
||||
airFrance.getAlternativeDepartureDate().setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
||||
airFrance.setBuyDate( new java.sql.Timestamp( 122367443 ) );
|
||||
airFrance.setFactor( 25 );
|
||||
s.persist( airFrance );
|
||||
tx.commit();
|
||||
s.close();
|
||||
|
||||
s = openSession();
|
||||
tx = s.beginTransaction();
|
||||
Query q = s.createQuery( "from Flight f where f.departureDate = :departureDate" );
|
||||
|
||||
Flight airFrance = doInHibernate( this::sessionFactory, session -> {
|
||||
Flight _airFrance = new Flight();
|
||||
_airFrance.setId( Long.valueOf( 747 ) );
|
||||
_airFrance.setName( "Paris-Amsterdam" );
|
||||
_airFrance.setDuration( Long.valueOf( 10 ) );
|
||||
_airFrance.setDepartureDate( Date.from(LocalDate.of( 2005, 06, 21 ).atStartOfDay(
|
||||
ZoneId.systemDefault()).toInstant()) );
|
||||
_airFrance.setAlternativeDepartureDate( new GregorianCalendar( 2006, 02, 03, 10, 00 ) );
|
||||
_airFrance.getAlternativeDepartureDate().setTimeZone( TimeZone.getTimeZone( "GMT" ) );
|
||||
_airFrance.setBuyDate( new java.sql.Timestamp( 122367443 ) );
|
||||
_airFrance.setFactor( 25 );
|
||||
session.persist( _airFrance );
|
||||
|
||||
return _airFrance;
|
||||
} );
|
||||
|
||||
doInHibernate( this::sessionFactory, session -> {
|
||||
Query q = session.createQuery( "from Flight f where f.departureDate = :departureDate" );
|
||||
q.setParameter( "departureDate", airFrance.getDepartureDate(), StandardBasicTypes.DATE );
|
||||
Flight copyAirFrance = (Flight) q.uniqueResult();
|
||||
assertNotNull( copyAirFrance );
|
||||
assertEquals(
|
||||
df.format( new Date( 05, 06, 21 ) ).toString(),
|
||||
df.format( copyAirFrance.getDepartureDate() ).toString()
|
||||
Date.from(LocalDate.of( 2005, 06, 21 ).atStartOfDay(
|
||||
ZoneId.systemDefault()).toInstant()),
|
||||
copyAirFrance.getDepartureDate()
|
||||
);
|
||||
assertEquals( df.format( airFrance.getBuyDate() ), df.format( copyAirFrance.getBuyDate() ) );
|
||||
|
||||
s.delete( copyAirFrance );
|
||||
tx.commit();
|
||||
s.close();
|
||||
session.delete( copyAirFrance );
|
||||
} );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.hibernate.boot.MetadataSources;
|
|||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.MySQL5InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
|
@ -37,7 +37,7 @@ import static org.junit.Assert.assertTrue;
|
|||
* @author Vlad Mihalcea
|
||||
*/
|
||||
@TestForIssue(jiraKey = "HHH-11236")
|
||||
@RequiresDialect(MySQL5InnoDBDialect.class)
|
||||
@RequiresDialect(MySQL5Dialect.class)
|
||||
public class MySQLDropConstraintThrowsExceptionTest extends BaseUnitTestCase {
|
||||
|
||||
@After
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.test.dialect.unit.lockhint;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.dialect.MySQL57Dialect;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
/**
|
||||
* @author Vlad Mihalcea
|
||||
*/
|
||||
public class MySQLStorageEngineTest extends BaseUnitTestCase {
|
||||
|
||||
@Test
|
||||
public void testDefaultStorage() {
|
||||
assertEquals(" engine=InnoDB", new MySQL57Dialect().getTableTypeString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverrideStorage() {
|
||||
String previousValue = System.setProperty( AvailableSettings.STORAGE_ENGINE, "myisam" );
|
||||
try{
|
||||
assertEquals(" engine=MyISAM", new MySQL57Dialect().getTableTypeString());
|
||||
}
|
||||
finally {
|
||||
if ( previousValue != null ) {
|
||||
System.setProperty( AvailableSettings.STORAGE_ENGINE, previousValue );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,7 +17,8 @@ import org.junit.Test;
|
|||
import org.hibernate.Query;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.Transaction;
|
||||
import org.hibernate.dialect.MySQL57InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQL57Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -29,7 +30,7 @@ import static org.junit.Assert.assertTrue;
|
|||
* @author Gail Badner.
|
||||
*/
|
||||
@TestForIssue( jiraKey = "HHH-8401")
|
||||
@RequiresDialect( MySQL57InnoDBDialect.class )
|
||||
@RequiresDialect( MySQL57Dialect.class )
|
||||
public class MySQL57TimestampFspFunctionTest extends BaseCoreFunctionalTestCase {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.hibernate.Session;
|
|||
import org.hibernate.annotations.ColumnDefault;
|
||||
import org.hibernate.annotations.Generated;
|
||||
import org.hibernate.annotations.GenerationTime;
|
||||
import org.hibernate.dialect.MySQL57InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQL57Dialect;
|
||||
|
||||
import org.hibernate.testing.RequiresDialect;
|
||||
import org.hibernate.testing.TestForIssue;
|
||||
|
@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals;
|
|||
/**
|
||||
* @author Gail Badner
|
||||
*/
|
||||
@RequiresDialect(value = MySQL57InnoDBDialect.class)
|
||||
@RequiresDialect(value = MySQL57Dialect.class)
|
||||
@TestForIssue( jiraKey = "HHH-8401")
|
||||
public class MySQL57TimestampPropertyTest extends BaseCoreFunctionalTestCase {
|
||||
private final DateFormat timestampFormat = new SimpleDateFormat("HH:mm:ss.SSS");
|
||||
|
|
|
@ -17,8 +17,8 @@ import javax.persistence.EntityManager;
|
|||
import javax.persistence.Query;
|
||||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.dialect.MySQL57Dialect;
|
||||
import org.hibernate.dialect.MariaDB53Dialect;
|
||||
import org.hibernate.dialect.MySQL57InnoDBDialect;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||
import org.hibernate.envers.configuration.EnversSettings;
|
||||
|
@ -476,7 +476,7 @@ public class ValidityAuditStrategyRevEndTsTest extends BaseEnversJPAFunctionalTe
|
|||
}
|
||||
else {
|
||||
if ( getDialect() instanceof MySQL5Dialect &&
|
||||
!( getDialect() instanceof MySQL57InnoDBDialect || getDialect() instanceof MariaDB53Dialect) ) {
|
||||
!( getDialect() instanceof MySQL57Dialect || getDialect() instanceof MariaDB53Dialect) ) {
|
||||
// MySQL5 DATETIME column type does not contain milliseconds.
|
||||
// MySQL 5.7 supports milliseconds and when MySQL57InnoDBDialect is used, it is assumed that
|
||||
// the column is defined as DATETIME(6).
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<property name="connection.username">sa</property>
|
||||
<property name="connection.password"></property>
|
||||
|
||||
<!--<property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property>-->
|
||||
<!--<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>-->
|
||||
<!--<property name="connection.url">jdbc:mysql:///hibernate_tests?useUnicode=true&characterEncoding=UTF-8</property>-->
|
||||
<!--<property name="connection.driver_class">com.mysql.jdbc.Driver</property>-->
|
||||
<!--<property name="connection.username">root</property>-->
|
||||
|
|
|
@ -12,7 +12,9 @@ package org.hibernate.spatial.dialect.mysql;
|
|||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
* creation-date: 9/13/13
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQL56InnoDBSpatialDialect extends MySQL56SpatialDialect {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -15,7 +15,7 @@ import java.util.Map;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.boot.model.TypeContributions;
|
||||
import org.hibernate.dialect.MySQL5Dialect;
|
||||
import org.hibernate.dialect.MySQL55Dialect;
|
||||
import org.hibernate.dialect.function.SQLFunction;
|
||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -34,7 +34,7 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
|||
*
|
||||
* @author Karel Maesen
|
||||
*/
|
||||
public class MySQL56SpatialDialect extends MySQL5Dialect implements SpatialDialect {
|
||||
public class MySQL56SpatialDialect extends MySQL55Dialect implements SpatialDialect {
|
||||
|
||||
|
||||
private MySQLSpatialDialect dialectDelegate = new MySQLSpatialDialect();
|
||||
|
|
|
@ -21,8 +21,9 @@ import org.hibernate.type.descriptor.sql.SqlTypeDescriptor;
|
|||
* A Dialect for MySQL 5 using InnoDB engine, with support for its spatial features
|
||||
*
|
||||
* @author Karel Maesen, Geovise BVBA
|
||||
*
|
||||
* @deprecated Use "hibernate.dialect.storage_engine=innodb" environment variable or JVM system property instead.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MySQL5InnoDBSpatialDialect extends MySQL5InnoDBDialect implements SpatialDialect {
|
||||
|
||||
private MySQLSpatialDialect dialectDelegate = new MySQLSpatialDialect();
|
||||
|
|
Loading…
Reference in New Issue