clean up the Dialect-specific default property handling

This commit is contained in:
Gavin King 2021-12-15 16:01:01 +01:00
parent 057b9bfc04
commit bc65526c77
20 changed files with 217 additions and 122 deletions

View File

@ -9,7 +9,6 @@ package org.hibernate.community.dialect;
import java.sql.Types; import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.identity.CUBRIDIdentityColumnSupport; import org.hibernate.community.dialect.identity.CUBRIDIdentityColumnSupport;
import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport; import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorCUBRIDDatabaseImpl; import org.hibernate.community.dialect.sequence.SequenceInformationExtractorCUBRIDDatabaseImpl;
@ -76,9 +75,10 @@ public class CUBRIDDialect extends Dialect {
registerColumnType( Types.BINARY, "bit($l)" ); registerColumnType( Types.BINARY, "bit($l)" );
registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "bit varying($l)" ); registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "bit varying($l)" );
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" ); registerCubridKeywords();
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); }
private void registerCubridKeywords() {
registerKeyword( "TYPE" ); registerKeyword( "TYPE" );
registerKeyword( "YEAR" ); registerKeyword( "YEAR" );
registerKeyword( "MONTH" ); registerKeyword( "MONTH" );
@ -116,6 +116,16 @@ public class CUBRIDDialect extends Dialect {
registerKeywords( info ); registerKeywords( info );
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
@Override
public boolean getDefaultUseStreamsForBinary() {
return true;
}
@Override @Override
public int getMaxVarcharLength() { public int getMaxVarcharLength() {
return 1_073_741_823; return 1_073_741_823;

View File

@ -71,11 +71,6 @@ public class CacheDialect extends Dialect {
registerColumnType( Types.BLOB, "image" ); registerColumnType( Types.BLOB, "image" );
registerColumnType( Types.CLOB, "text" ); registerColumnType( Types.CLOB, "text" );
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
getDefaultProperties().setProperty( Environment.USE_SQL_COMMENTS, "false" );
} }
public CacheDialect(DialectResolutionInfo info) { public CacheDialect(DialectResolutionInfo info) {
@ -83,6 +78,17 @@ public class CacheDialect extends Dialect {
registerKeywords( info ); registerKeywords( info );
} }
@Override
protected void initDefaultProperties() {
super.initDefaultProperties();
getDefaultProperties().setProperty( Environment.USE_SQL_COMMENTS, "false" );
}
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
private static void useJdbcEscape(QueryEngine queryEngine, String name) { private static void useJdbcEscape(QueryEngine queryEngine, String name) {
//Yep, this seems to be truly necessary for certain functions //Yep, this seems to be truly necessary for certain functions
queryEngine.getSqmFunctionRegistry().wrapInJdbcEscape( queryEngine.getSqmFunctionRegistry().wrapInJdbcEscape(

View File

@ -19,7 +19,6 @@ import java.util.regex.Pattern;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.identity.FirebirdIdentityColumnSupport; import org.hibernate.community.dialect.identity.FirebirdIdentityColumnSupport;
import org.hibernate.community.dialect.pagination.SkipFirstLimitHandler; import org.hibernate.community.dialect.pagination.SkipFirstLimitHandler;
import org.hibernate.community.dialect.sequence.FirebirdSequenceSupport; import org.hibernate.community.dialect.sequence.FirebirdSequenceSupport;
@ -153,8 +152,6 @@ public class FirebirdDialect extends Dialect {
registerColumnType( Types.BLOB, "blob sub_type binary" ); registerColumnType( Types.BLOB, "blob sub_type binary" );
registerColumnType( Types.CLOB, "blob sub_type text" ); registerColumnType( Types.CLOB, "blob sub_type text" );
registerColumnType( Types.NCLOB, "blob sub_type text" ); // Firebird doesn't have NCLOB, but Jaybird emulates NCLOB support registerColumnType( Types.NCLOB, "blob sub_type text" ); // Firebird doesn't have NCLOB, but Jaybird emulates NCLOB support
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
} }
@Override @Override
@ -174,6 +171,11 @@ public class FirebirdDialect extends Dialect {
return version; return version;
} }
@Override
public int getDefaultStatementBatchSize() {
return 0;
}
@Override @Override
public TimeZoneSupport getTimeZoneSupport() { public TimeZoneSupport getTimeZoneSupport() {
return getVersion().isSameOrAfter( 4, 0 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE; return getVersion().isSameOrAfter( 4, 0 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;

View File

@ -8,7 +8,6 @@ package org.hibernate.community.dialect;
import java.sql.Types; import java.sql.Types;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.identity.Ingres10IdentityColumnSupport; import org.hibernate.community.dialect.identity.Ingres10IdentityColumnSupport;
import org.hibernate.community.dialect.identity.Ingres9IdentityColumnSupport; import org.hibernate.community.dialect.identity.Ingres9IdentityColumnSupport;
import org.hibernate.community.dialect.pagination.FirstLimitHandler; import org.hibernate.community.dialect.pagination.FirstLimitHandler;
@ -144,6 +143,30 @@ public class IngresDialect extends Dialect {
registerColumnType( Types.DATE, "ansidate" ); registerColumnType( Types.DATE, "ansidate" );
} }
limitHandler = getVersion().isBefore( 9, 3 ) ? FirstLimitHandler.INSTANCE : IngresLimitHandler.INSTANCE;
sequenceSupport = new ANSISequenceSupport() {
@Override
public boolean supportsPooledSequences() {
return getVersion().isSameOrAfter( 9, 3 );
}
};
}
// @Override
// protected void initDefaultProperties() {
// super.initDefaultProperties();
//
// if ( getVersion().isBefore( 10 ) ) {
// // There is no support for a native boolean type that accepts values
// // of true, false or unknown. Using the tinyint type requires
// // substitutions of true and false.
// getDefaultProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, "true=1,false=0" );
// }
// }
@Override
public boolean getDefaultUseGetGeneratedKeys() {
// Ingres driver supports getGeneratedKeys but only in the following // Ingres driver supports getGeneratedKeys but only in the following
// form: // form:
// The Ingres DBMS returns only a single table key or a single object // The Ingres DBMS returns only a single table key or a single object
@ -154,23 +177,7 @@ public class IngresDialect extends Dialect {
// ignored and getGeneratedKeys() returns a result-set containing no // ignored and getGeneratedKeys() returns a result-set containing no
// rows, a single row with one column, or a single row with two columns. // rows, a single row with one column, or a single row with two columns.
// Ingres JDBC Driver returns table and object keys as BINARY values. // Ingres JDBC Driver returns table and object keys as BINARY values.
getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" ); return false;
if ( getVersion().isBefore( 10 ) ) {
// There is no support for a native boolean type that accepts values
// of true, false or unknown. Using the tinyint type requires
// substitutions of true and false.
getDefaultProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, "true=1,false=0" );
}
limitHandler = getVersion().isBefore( 9, 3 ) ? FirstLimitHandler.INSTANCE : IngresLimitHandler.INSTANCE;
sequenceSupport = new ANSISequenceSupport() {
@Override
public boolean supportsPooledSequences() {
return getVersion().isSameOrAfter( 9, 3 );
}
};
} }
@Override @Override

View File

@ -10,7 +10,6 @@ import java.sql.DatabaseMetaData;
import java.sql.Types; import java.sql.Types;
import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport; import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorSAPDBDatabaseImpl; import org.hibernate.community.dialect.sequence.SequenceInformationExtractorSAPDBDatabaseImpl;
import org.hibernate.dialect.AbstractTransactSQLDialect; import org.hibernate.dialect.AbstractTransactSQLDialect;
@ -64,8 +63,6 @@ public class MaxDBDialect extends Dialect {
registerColumnType( Types.CLOB, "long varchar" ); registerColumnType( Types.CLOB, "long varchar" );
registerColumnType( Types.BLOB, "long byte" ); registerColumnType( Types.BLOB, "long byte" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
} }
@Override @Override
@ -107,6 +104,11 @@ public class MaxDBDialect extends Dialect {
return ZERO_VERSION; return ZERO_VERSION;
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
@Override @Override
public LimitHandler getLimitHandler() { public LimitHandler getLimitHandler() {
return LimitOffsetLimitHandler.INSTANCE; return LimitOffsetLimitHandler.INSTANCE;

View File

@ -10,7 +10,6 @@ import java.sql.Types;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.cfg.Environment;
import org.hibernate.community.dialect.identity.MimerSQLIdentityColumnSupport; import org.hibernate.community.dialect.identity.MimerSQLIdentityColumnSupport;
import org.hibernate.community.dialect.sequence.MimerSequenceSupport; import org.hibernate.community.dialect.sequence.MimerSequenceSupport;
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorMimerSQLDatabaseImpl; import org.hibernate.community.dialect.sequence.SequenceInformationExtractorMimerSQLDatabaseImpl;
@ -78,9 +77,6 @@ public class MimerSQLDialect extends Dialect {
registerColumnType( Types.NCLOB, "nclob($l)" ); registerColumnType( Types.NCLOB, "nclob($l)" );
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" ); registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" );
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, "50" );
} }
public MimerSQLDialect(DialectResolutionInfo info) { public MimerSQLDialect(DialectResolutionInfo info) {
@ -106,6 +102,16 @@ public class MimerSQLDialect extends Dialect {
return ZERO_VERSION; return ZERO_VERSION;
} }
@Override
public int getDefaultStatementBatchSize() {
return 50;
}
@Override
public boolean getDefaultUseStreamsForBinary() {
return true;
}
@Override @Override
public void initializeFunctionRegistry(QueryEngine queryEngine) { public void initializeFunctionRegistry(QueryEngine queryEngine) {
super.initializeFunctionRegistry( queryEngine ); super.initializeFunctionRegistry( queryEngine );

View File

@ -7,7 +7,6 @@
package org.hibernate.community.dialect; package org.hibernate.community.dialect;
import java.sql.Types;
import java.util.Map; import java.util.Map;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;

View File

@ -115,18 +115,17 @@ public class TeradataDialect extends Dialect {
registerKeyword( "role" ); registerKeyword( "role" );
registerKeyword( "account" ); registerKeyword( "account" );
registerKeyword( "class" ); registerKeyword( "class" );
}
if ( getVersion().isBefore( 14 ) ) { @Override
// use getBytes instead of getBinaryStream public int getDefaultStatementBatchSize() {
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" ); return getVersion().isBefore( 14 )
// no batch statements ? 0 : 15;
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH ); }
}
else {
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
}
@Override
public boolean getDefaultUseStreamsForBinary() {
return getVersion().isSameOrAfter( 14 );
} }
@Override @Override

View File

@ -8,7 +8,6 @@ package org.hibernate.community.dialect;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.DatabaseVersion; import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.dialect.RowLockStrategy; import org.hibernate.dialect.RowLockStrategy;
@ -95,9 +94,6 @@ public class TimesTenDialect extends Dialect {
//`timestamp` has more precision than `tt_timestamp` //`timestamp` has more precision than `tt_timestamp`
// registerColumnType(Types.TIMESTAMP, "tt_timestamp"); // registerColumnType(Types.TIMESTAMP, "tt_timestamp");
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" ); registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" );
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
} }
public TimesTenDialect(DialectResolutionInfo info) { public TimesTenDialect(DialectResolutionInfo info) {
@ -110,6 +106,16 @@ public class TimesTenDialect extends Dialect {
return ZERO_VERSION; return ZERO_VERSION;
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
@Override
public boolean getDefaultUseStreamsForBinary() {
return true;
}
@Override @Override
public JdbcType resolveSqlTypeDescriptor( public JdbcType resolveSqlTypeDescriptor(
String columnTypeName, String columnTypeName,

View File

@ -13,7 +13,6 @@ import org.hibernate.boot.Metadata;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.naming.Identifier; import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.SqlStringGenerationContext; import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.function.CommonFunctionFactory; import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.HANAIdentityColumnSupport; import org.hibernate.dialect.identity.HANAIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport; import org.hibernate.dialect.identity.IdentityColumnSupport;
@ -215,12 +214,18 @@ public abstract class AbstractHANADialect extends Dialect {
registerColumnType( SqlTypes.POINT, "st_point" ); registerColumnType( SqlTypes.POINT, "st_point" );
registerHanaKeywords(); registerHanaKeywords();
}
@Override
public boolean getDefaultNonContextualLobCreation() {
// createBlob() and createClob() are not supported by the HANA JDBC driver // createBlob() and createClob() are not supported by the HANA JDBC driver
getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" ); return true;
}
@Override
public boolean getDefaultUseGetGeneratedKeys() {
// getGeneratedKeys() is not supported by the HANA JDBC driver // getGeneratedKeys() is not supported by the HANA JDBC driver
getDefaultProperties().setProperty( AvailableSettings.USE_GET_GENERATED_KEYS, "false" ); return false;
} }
@Override @Override

View File

@ -51,10 +51,6 @@ import static org.hibernate.type.SqlTypes.*;
*/ */
public abstract class AbstractTransactSQLDialect extends Dialect { public abstract class AbstractTransactSQLDialect extends Dialect {
{
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
public AbstractTransactSQLDialect(DatabaseVersion version) { public AbstractTransactSQLDialect(DatabaseVersion version) {
super(version); super(version);
} }
@ -96,6 +92,11 @@ public abstract class AbstractTransactSQLDialect extends Dialect {
} }
} }
@Override
public int getDefaultStatementBatchSize() {
return 0;
}
@Override @Override
public JdbcType resolveSqlTypeDescriptor( public JdbcType resolveSqlTypeDescriptor(
String columnTypeName, String columnTypeName,

View File

@ -82,10 +82,6 @@ public class DB2Dialect extends Dialect {
: DB2LimitHandler.INSTANCE; : DB2LimitHandler.INSTANCE;
private final UniqueDelegate uniqueDelegate = createUniqueDelegate(); private final UniqueDelegate uniqueDelegate = createUniqueDelegate();
{
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
public DB2Dialect() { public DB2Dialect() {
this( DatabaseVersion.make( 9, 0 ) ); this( DatabaseVersion.make( 9, 0 ) );
} }
@ -113,6 +109,11 @@ public class DB2Dialect extends Dialect {
registerKeyword( "only" ); registerKeyword( "only" );
} }
@Override
public int getDefaultStatementBatchSize() {
return 0;
}
@Override @Override
protected String columnType(int jdbcTypeCode) { protected String columnType(int jdbcTypeCode) {
if ( getVersion().isBefore( 11 ) ) { if ( getVersion().isBefore( 11 ) ) {

View File

@ -9,7 +9,6 @@ package org.hibernate.dialect;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.CommonFunctionFactory; import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.function.CastingConcatFunction; import org.hibernate.dialect.function.CastingConcatFunction;
import org.hibernate.dialect.function.DerbyLpadEmulation; import org.hibernate.dialect.function.DerbyLpadEmulation;
@ -96,10 +95,6 @@ public class DerbyDialect extends Dialect {
? AbstractLimitHandler.NO_LIMIT ? AbstractLimitHandler.NO_LIMIT
: new DerbyLimitHandler( getVersion().isSameOrAfter( 10, 6 ) ); : new DerbyLimitHandler( getVersion().isSameOrAfter( 10, 6 ) );
{
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
}
public DerbyDialect() { public DerbyDialect() {
this( DatabaseVersion.make( 10, 0 ) ); this( DatabaseVersion.make( 10, 0 ) );
} }
@ -196,6 +191,11 @@ public class DerbyDialect extends Dialect {
return NationalizationSupport.IMPLICIT; return NationalizationSupport.IMPLICIT;
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
@Override @Override
public int getFloatPrecision() { public int getFloatPrecision() {
return 23; return 23;

View File

@ -49,6 +49,7 @@ import org.hibernate.boot.model.TypeContributions;
import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject; import org.hibernate.boot.model.relational.AuxiliaryDatabaseObject;
import org.hibernate.boot.model.relational.Sequence; import org.hibernate.boot.model.relational.Sequence;
import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.boot.spi.SessionFactoryOptions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.CastFunction; import org.hibernate.dialect.function.CastFunction;
import org.hibernate.dialect.function.CastStrEmulation; import org.hibernate.dialect.function.CastStrEmulation;
import org.hibernate.dialect.function.CoalesceIfnullEmulation; import org.hibernate.dialect.function.CoalesceIfnullEmulation;
@ -189,16 +190,6 @@ import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithM
*/ */
public abstract class Dialect implements ConversionContext { public abstract class Dialect implements ConversionContext {
/**
* Defines a default batch size constant
*/
public static final String DEFAULT_BATCH_SIZE = "15";
/**
* Defines a "no batching" batch size constant
*/
protected static final String NO_BATCH = "0";
/** /**
* Characters used as opening for quoting SQL identifiers * Characters used as opening for quoting SQL identifiers
*/ */
@ -243,6 +234,7 @@ public abstract class Dialect implements ConversionContext {
registerDefaultColumnTypes(); registerDefaultColumnTypes();
registerHibernateTypes(); registerHibernateTypes();
registerDefaultKeywords(); registerDefaultKeywords();
initDefaultProperties();
} }
protected Dialect(DialectResolutionInfo info) { protected Dialect(DialectResolutionInfo info) {
@ -252,6 +244,21 @@ public abstract class Dialect implements ConversionContext {
registerHibernateTypes(); registerHibernateTypes();
registerDefaultKeywords(); registerDefaultKeywords();
registerKeywords(info); registerKeywords(info);
initDefaultProperties();
}
/**
* Set appropriate default values for configuration properties.
*/
protected void initDefaultProperties() {
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE,
Integer.toString( getDefaultStatementBatchSize() ) );
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY,
Boolean.toString( getDefaultUseStreamsForBinary() ) );
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION,
Boolean.toString( getDefaultNonContextualLobCreation() ) );
getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS,
Boolean.toString( getDefaultUseGetGeneratedKeys() ) );
} }
/** /**
@ -1311,6 +1318,38 @@ public abstract class Dialect implements ConversionContext {
return properties; return properties;
} }
/**
* The default value to use for the configuration property
* {@link Environment#STATEMENT_BATCH_SIZE}.
*/
public int getDefaultStatementBatchSize() {
return 1;
}
/**
* The default value to use for the configuration property
* {@link Environment#USE_STREAMS_FOR_BINARY}.
*/
public boolean getDefaultUseStreamsForBinary() {
return false;
}
/**
* The default value to use for the configuration property
* {@link Environment#NON_CONTEXTUAL_LOB_CREATION}.
*/
public boolean getDefaultNonContextualLobCreation() {
return false;
}
/**
* The default value to use for the configuration property
* {@link Environment#USE_GET_GENERATED_KEYS}.
*/
public boolean getDefaultUseGetGeneratedKeys() {
return true;
}
@Override @Override
public String toString() { public String toString() {
return getClass().getName(); return getClass().getName();

View File

@ -12,7 +12,6 @@ import java.util.List;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.function.CommonFunctionFactory; import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.hint.IndexQueryHintHandler; import org.hibernate.dialect.hint.IndexQueryHintHandler;
import org.hibernate.dialect.identity.H2IdentityColumnSupport; import org.hibernate.dialect.identity.H2IdentityColumnSupport;
@ -84,12 +83,6 @@ public class H2Dialect extends Dialect {
private final SequenceInformationExtractor sequenceInformationExtractor; private final SequenceInformationExtractor sequenceInformationExtractor;
private final String querySequenceString; private final String querySequenceString;
{
getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
// http://code.google.com/p/h2database/issues/detail?id=235
getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" );
}
public H2Dialect(DialectResolutionInfo info) { public H2Dialect(DialectResolutionInfo info) {
this( parseVersion( info ) ); this( parseVersion( info ) );
registerKeywords( info ); registerKeywords( info );
@ -151,6 +144,12 @@ public class H2Dialect extends Dialect {
return bits.length > 2 ? Integer.parseInt( bits[2] ) : 0; return bits.length > 2 ? Integer.parseInt( bits[2] ) : 0;
} }
@Override
public boolean getDefaultNonContextualLobCreation() {
// http://code.google.com/p/h2database/issues/detail?id=235
return true;
}
@Override @Override
protected String columnType(int jdbcTypeCode) { protected String columnType(int jdbcTypeCode) {
if ( jdbcTypeCode == NUMERIC && getVersion().isBefore(2) ) { if ( jdbcTypeCode == NUMERIC && getVersion().isBefore(2) ) {
@ -194,6 +193,11 @@ public class H2Dialect extends Dialect {
} }
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
public boolean hasOddDstBehavior() { public boolean hasOddDstBehavior() {
// H2 1.4.200 has a bug: https://github.com/h2database/h2database/issues/3184 // H2 1.4.200 has a bug: https://github.com/h2database/h2database/issues/3184
return getVersion().isSame( 1, 4, 200 ); return getVersion().isSame( 1, 4, 200 );

View File

@ -12,7 +12,6 @@ import java.sql.Types;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.StaleObjectStateException; import org.hibernate.StaleObjectStateException;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.CommonFunctionFactory; import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.HSQLIdentityColumnSupport; import org.hibernate.dialect.identity.HSQLIdentityColumnSupport;
import org.hibernate.dialect.identity.IdentityColumnSupport; import org.hibernate.dialect.identity.IdentityColumnSupport;
@ -89,10 +88,6 @@ public class HSQLDialect extends Dialect {
HSQLDialect.class.getName() HSQLDialect.class.getName()
); );
{
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
}
public HSQLDialect(DialectResolutionInfo info) { public HSQLDialect(DialectResolutionInfo info) {
this( info.makeCopy() ); this( info.makeCopy() );
registerKeywords( info ); registerKeywords( info );
@ -143,6 +138,11 @@ public class HSQLDialect extends Dialect {
return super.columnType(jdbcTypeCode); return super.columnType(jdbcTypeCode);
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
private static DatabaseVersion reflectedVersion(DatabaseVersion version) { private static DatabaseVersion reflectedVersion(DatabaseVersion version) {
try { try {
final Class<?> props = ReflectHelper.classForName("org.hsqldb.persist.HsqlDatabaseProperties"); final Class<?> props = ReflectHelper.classForName("org.hsqldb.persist.HsqlDatabaseProperties");

View File

@ -108,11 +108,6 @@ public class MySQLDialect extends Dialect {
} }
}; };
{
getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" );
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
}
private int maxVarcharLength; private int maxVarcharLength;
private int maxVarbinaryLength; private int maxVarbinaryLength;
@ -123,13 +118,18 @@ public class MySQLDialect extends Dialect {
public MySQLDialect(DatabaseVersion version) { public MySQLDialect(DatabaseVersion version) {
super(version); super(version);
registerKeyword( "key" ); registerKeyword( "key" );
} }
public MySQLDialect(DialectResolutionInfo info) { public MySQLDialect(DialectResolutionInfo info) {
super(info); super(info);
} }
@Override
protected void initDefaultProperties() {
super.initDefaultProperties();
getDefaultProperties().setProperty( Environment.MAX_FETCH_DEPTH, "2" );
}
private MySQLStorageEngine createStorageEngine() { private MySQLStorageEngine createStorageEngine() {
String storageEngine = Environment.getProperties().getProperty( Environment.STORAGE_ENGINE ); String storageEngine = Environment.getProperties().getProperty( Environment.STORAGE_ENGINE );
if (storageEngine == null) { if (storageEngine == null) {

View File

@ -116,12 +116,10 @@ public class OracleDialect extends Dialect {
public OracleDialect(DatabaseVersion version) { public OracleDialect(DatabaseVersion version) {
super(version); super(version);
registerDefaultProperties();
} }
public OracleDialect(DialectResolutionInfo info) { public OracleDialect(DialectResolutionInfo info) {
super(info); super(info);
registerDefaultProperties();
} }
@Override @Override
@ -592,22 +590,30 @@ public class OracleDialect extends Dialect {
return getVersion().isSameOrAfter( 9 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE; return getVersion().isSameOrAfter( 9 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
} }
protected void registerDefaultProperties() { @Override
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" ); protected void initDefaultProperties() {
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); super.initDefaultProperties();
String newerVersion = Boolean.toString( getVersion().isSameOrAfter( 12 ) );
getDefaultProperties().setProperty( Environment.BATCH_VERSIONED_DATA, newerVersion );
}
if ( getVersion().isBefore( 12 ) ) { @Override
// Oracle driver reports to support getGeneratedKeys(), but they only public int getDefaultStatementBatchSize() {
// support the version taking an array of the names of the columns to return 15;
// be returned (via its RETURNING clause). No other driver seems to }
// support this overloaded version.
getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" ); @Override
getDefaultProperties().setProperty( Environment.BATCH_VERSIONED_DATA, "false" ); public boolean getDefaultUseStreamsForBinary() {
} return true;
else { }
getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "true" );
getDefaultProperties().setProperty( Environment.BATCH_VERSIONED_DATA, "true" ); @Override
} public boolean getDefaultUseGetGeneratedKeys() {
// Oracle driver reports to support getGeneratedKeys(), but they only
// support the version taking an array of the names of the columns to
// be returned (via its RETURNING clause). No other driver seems to
// support this overloaded version.
return getVersion().isSameOrAfter( 12 );
} }
@Override @Override

View File

@ -26,7 +26,6 @@ import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
import org.hibernate.QueryTimeoutException; import org.hibernate.QueryTimeoutException;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
import org.hibernate.cfg.Environment;
import org.hibernate.dialect.function.CommonFunctionFactory; import org.hibernate.dialect.function.CommonFunctionFactory;
import org.hibernate.dialect.identity.IdentityColumnSupport; import org.hibernate.dialect.identity.IdentityColumnSupport;
import org.hibernate.dialect.identity.PostgreSQLIdentityColumnSupport; import org.hibernate.dialect.identity.PostgreSQLIdentityColumnSupport;
@ -101,11 +100,6 @@ public class PostgreSQLDialect extends Dialect {
private final PostgreSQLDriverKind driverKind; private final PostgreSQLDriverKind driverKind;
{
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
getDefaultProperties().setProperty( Environment.NON_CONTEXTUAL_LOB_CREATION, "true" );
}
public PostgreSQLDialect() { public PostgreSQLDialect() {
this( DatabaseVersion.make( 8, 0 ) ); this( DatabaseVersion.make( 8, 0 ) );
} }
@ -125,6 +119,11 @@ public class PostgreSQLDialect extends Dialect {
this.driverKind = driverKind; this.driverKind = driverKind;
} }
@Override
public boolean getDefaultNonContextualLobCreation() {
return true;
}
@Override @Override
protected String columnType(int jdbcTypeCode) { protected String columnType(int jdbcTypeCode) {
switch (jdbcTypeCode) { switch (jdbcTypeCode) {
@ -213,6 +212,11 @@ public class PostgreSQLDialect extends Dialect {
return super.getTypeName( code, size ); return super.getTypeName( code, size );
} }
@Override
public int getDefaultStatementBatchSize() {
return 15;
}
@Override @Override
public JdbcType resolveSqlTypeDescriptor( public JdbcType resolveSqlTypeDescriptor(
String columnTypeName, String columnTypeName,

View File

@ -52,10 +52,8 @@ public class StandardJdbcMutationExecutor implements JdbcMutationExecutor {
finalSql = jdbcMutation.getSql(); finalSql = jdbcMutation.getSql();
} }
else { else {
final Dialect dialect = jdbcServices.getDialect(); finalSql = jdbcServices.getDialect().addSqlHintOrComment(
final String sql = jdbcMutation.getSql(); jdbcMutation.getSql(),
finalSql = dialect.addSqlHintOrComment(
sql,
queryOptions, queryOptions,
executionContext.getSession().getFactory().getSessionFactoryOptions().isCommentsEnabled() executionContext.getSession().getFactory().getSessionFactoryOptions().isCommentsEnabled()
); );