@Test public void testDefaultStorage() { assertEquals( " engine=InnoDB", new MySQL57Dialect().getTableTypeString() ); }
@Override public String getWriteLockString(int timeout) { if ( timeout == LockOptions.NO_WAIT ) { return getForUpdateNowaitString(); } else if ( timeout == LockOptions.SKIP_LOCKED ) { return getForUpdateSkipLockedString(); } return super.getWriteLockString( timeout ); }
registerColumnType( Types.TIMESTAMP, "datetime(6)" ); registerColumnType( Types.JAVA_OBJECT, "json" ); registerFunction( "now", currentTimestampFunction ); registerFunction( "current_timestamp", currentTimestampFunction ); registerFunction( "localtime", currentTimestampFunction ); registerFunction( "localtimestamp", currentTimestampFunction ); registerFunction( "sysdate", new StaticPrecisionFspTimestampFunction( "sysdate", 6 ) );
@Override public Dialect resolveDialect(DialectResolutionInfo info) { final String databaseName = info.getDatabaseName(); if ( "MySQL".equals( databaseName ) ) { final int majorVersion = info.getDatabaseMajorVersion(); final int minorVersion = info.getDatabaseMinorVersion(); if ( majorVersion < 5 ) { return new MySQLDialect(); } else if ( majorVersion == 5 ) { if ( minorVersion < 5 ) { return new MySQL5Dialect(); } else if ( minorVersion < 7 ) { return new MySQL55Dialect(); } else { return new MySQL57Dialect(); } } return latestDialectInstance( this ); } return null; } },
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" ); }
@Override public Dialect resolveDialect(DialectResolutionInfo info) { final String databaseName = info.getDatabaseName(); if ( "MySQL".equals( databaseName ) ) { final int majorVersion = info.getDatabaseMajorVersion(); final int minorVersion = info.getDatabaseMinorVersion(); if ( majorVersion < 5 ) { return new MySQLDialect(); } else if ( majorVersion == 5 ) { if ( minorVersion < 5 ) { return new MySQL5Dialect(); } else if ( minorVersion < 7 ) { return new MySQL55Dialect(); } else { return new MySQL57Dialect(); } } return latestDialectInstance( this ); } return null; } },
@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 ); } else { System.clearProperty( AvailableSettings.STORAGE_ENGINE ); assertThat( System.getProperty( AvailableSettings.STORAGE_ENGINE ), is( nullValue() ) ); } } } }
@Override public String getWriteLockString(String aliases, int timeout) { if ( timeout == LockOptions.NO_WAIT ) { return getForUpdateNowaitString(aliases); } else if ( timeout == LockOptions.SKIP_LOCKED ) { return getForUpdateSkipLockedString(aliases); } return super.getWriteLockString( aliases, timeout ); }
@Override public String getWriteLockString(String aliases, int timeout) { if ( timeout == LockOptions.NO_WAIT ) { return getForUpdateNowaitString(aliases); } else if ( timeout == LockOptions.SKIP_LOCKED ) { return getForUpdateSkipLockedString(aliases); } return super.getWriteLockString( aliases, timeout ); }
@Override public String getWriteLockString(int timeout) { if ( timeout == LockOptions.NO_WAIT ) { return getForUpdateNowaitString(); } else if ( timeout == LockOptions.SKIP_LOCKED ) { return getForUpdateSkipLockedString(); } return super.getWriteLockString( timeout ); }