mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-16 16:15:06 +00:00
Dialect version
This commit is contained in:
parent
d354d49ab1
commit
10d759e139
@ -6,17 +6,21 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.community.dialect.identity.CUBRIDIdentityColumnSupport;
|
||||||
|
import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport;
|
||||||
|
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorCUBRIDDatabaseImpl;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.OracleDialect;
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.dialect.TimeZoneSupport;
|
import org.hibernate.dialect.TimeZoneSupport;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
import org.hibernate.community.dialect.identity.CUBRIDIdentityColumnSupport;
|
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitLimitHandler;
|
import org.hibernate.dialect.pagination.LimitLimitHandler;
|
||||||
import org.hibernate.community.dialect.sequence.CUBRIDSequenceSupport;
|
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
@ -31,16 +35,17 @@
|
|||||||
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
||||||
import org.hibernate.sql.ast.tree.Statement;
|
import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorCUBRIDDatabaseImpl;
|
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.query.TemporalUnit.*;
|
import static org.hibernate.query.TemporalUnit.HOUR;
|
||||||
|
import static org.hibernate.query.TemporalUnit.MINUTE;
|
||||||
|
import static org.hibernate.query.TemporalUnit.NANOSECOND;
|
||||||
|
import static org.hibernate.query.TemporalUnit.NATIVE;
|
||||||
|
import static org.hibernate.query.TemporalUnit.SECOND;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for CUBRID (8.3.x and later).
|
* An SQL dialect for CUBRID (8.3.x and later).
|
||||||
@ -48,6 +53,7 @@
|
|||||||
* @author Seok Jeong Il
|
* @author Seok Jeong Il
|
||||||
*/
|
*/
|
||||||
public class CUBRIDDialect extends Dialect {
|
public class CUBRIDDialect extends Dialect {
|
||||||
|
private static final DatabaseVersion VERSION = DatabaseVersion.make( 0, 0 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a CUBRIDDialect
|
* Constructs a CUBRIDDialect
|
||||||
@ -110,8 +116,8 @@ public CUBRIDDialect(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.OracleDialect;
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
@ -55,6 +56,7 @@
|
|||||||
* @author Jonathan Levinson
|
* @author Jonathan Levinson
|
||||||
*/
|
*/
|
||||||
public class CacheDialect extends Dialect {
|
public class CacheDialect extends Dialect {
|
||||||
|
private final DatabaseVersion version = DatabaseVersion.make( 0, 0 );
|
||||||
|
|
||||||
public CacheDialect() {
|
public CacheDialect() {
|
||||||
super();
|
super();
|
||||||
@ -90,8 +92,8 @@ private static void useJdbcEscape(QueryEngine queryEngine, String name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,22 +6,33 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.dialect.BooleanDecoder;
|
|
||||||
import org.hibernate.dialect.Dialect;
|
|
||||||
import org.hibernate.dialect.TimeZoneSupport;
|
|
||||||
import org.hibernate.query.IntervalType;
|
|
||||||
import org.hibernate.query.NullOrdering;
|
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
|
||||||
import org.hibernate.community.dialect.identity.FirebirdIdentityColumnSupport;
|
import org.hibernate.community.dialect.identity.FirebirdIdentityColumnSupport;
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
|
||||||
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
|
||||||
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;
|
||||||
import org.hibernate.community.dialect.sequence.InterbaseSequenceSupport;
|
import org.hibernate.community.dialect.sequence.InterbaseSequenceSupport;
|
||||||
|
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorFirebirdDatabaseImpl;
|
||||||
|
import org.hibernate.dialect.BooleanDecoder;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.TimeZoneSupport;
|
||||||
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
|
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
|
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
@ -37,6 +48,8 @@
|
|||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.query.CastType;
|
import org.hibernate.query.CastType;
|
||||||
|
import org.hibernate.query.IntervalType;
|
||||||
|
import org.hibernate.query.NullOrdering;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||||
@ -52,7 +65,6 @@
|
|||||||
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
||||||
import org.hibernate.sql.ast.tree.Statement;
|
import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorFirebirdDatabaseImpl;
|
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceNameExtractorImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceNameExtractorImpl;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
@ -61,17 +73,6 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.DatabaseMetaData;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_END;
|
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_END;
|
||||||
@ -91,14 +92,15 @@
|
|||||||
*/
|
*/
|
||||||
public class FirebirdDialect extends Dialect {
|
public class FirebirdDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public FirebirdDialect() {
|
public FirebirdDialect() {
|
||||||
this( 250 );
|
this( DatabaseVersion.make( 2, 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public FirebirdDialect(DialectResolutionInfo info) {
|
public FirebirdDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,11 +112,11 @@ public FirebirdDialect(DialectResolutionInfo info) {
|
|||||||
// * can't select a parameter unless wrapped in a
|
// * can't select a parameter unless wrapped in a
|
||||||
// cast (not even when wrapped in a function call)
|
// cast (not even when wrapped in a function call)
|
||||||
|
|
||||||
public FirebirdDialect(int version) {
|
public FirebirdDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
if ( getVersion() < 300 ) {
|
if ( version.isBefore( 3, 0 ) ) {
|
||||||
//'boolean' type introduced in 3.0
|
//'boolean' type introduced in 3.0
|
||||||
registerColumnType( Types.BOOLEAN, "smallint" );
|
registerColumnType( Types.BOOLEAN, "smallint" );
|
||||||
}
|
}
|
||||||
@ -131,7 +133,7 @@ public FirebirdDialect(int version) {
|
|||||||
|
|
||||||
//no precision for 'timestamp' type
|
//no precision for 'timestamp' type
|
||||||
registerColumnType( Types.TIMESTAMP, "timestamp" );
|
registerColumnType( Types.TIMESTAMP, "timestamp" );
|
||||||
if ( getVersion() < 400 ) {
|
if ( getVersion().isBefore( 4, 0 ) ) {
|
||||||
// No time zone support, map to without time zone types
|
// No time zone support, map to without time zone types
|
||||||
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
|
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
|
||||||
registerColumnType( Types.TIME_WITH_TIMEZONE, "time" );
|
registerColumnType( Types.TIME_WITH_TIMEZONE, "time" );
|
||||||
@ -143,7 +145,7 @@ public FirebirdDialect(int version) {
|
|||||||
registerColumnType( Types.VARCHAR, 8_191, "varchar($l)" );
|
registerColumnType( Types.VARCHAR, 8_191, "varchar($l)" );
|
||||||
registerColumnType( Types.VARCHAR, "blob sub_type text" );
|
registerColumnType( Types.VARCHAR, "blob sub_type text" );
|
||||||
|
|
||||||
if ( getVersion() < 400 ) {
|
if ( getVersion().isBefore( 4, 0 ) ) {
|
||||||
registerColumnType( Types.BINARY, 32_767, "char($l) character set octets" );
|
registerColumnType( Types.BINARY, 32_767, "char($l) character set octets" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -151,7 +153,7 @@ public FirebirdDialect(int version) {
|
|||||||
}
|
}
|
||||||
registerColumnType( Types.BINARY, "blob sub_type binary" );
|
registerColumnType( Types.BINARY, "blob sub_type binary" );
|
||||||
|
|
||||||
if ( getVersion() < 400 ) {
|
if ( getVersion().isBefore( 4, 0 ) ) {
|
||||||
registerColumnType( Types.VARBINARY, 32_765, "varchar($l) character set octets" );
|
registerColumnType( Types.VARBINARY, 32_765, "varchar($l) character set octets" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -167,13 +169,13 @@ public FirebirdDialect(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeZoneSupport getTimeZoneSupport() {
|
public TimeZoneSupport getTimeZoneSupport() {
|
||||||
return getVersion() >= 400 ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
return getVersion().isSince( 4, 0 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -197,14 +199,14 @@ public JdbcType resolveSqlTypeDescriptor(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return getVersion() < 300
|
return getVersion().isBefore( 3, 0 )
|
||||||
? Types.BIT
|
? Types.BIT
|
||||||
: super.getPreferredSqlTypeCodeForBoolean();
|
: super.getPreferredSqlTypeCodeForBoolean();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeName(int code, Size size) throws HibernateException {
|
public String getTypeName(int code, Size size) throws HibernateException {
|
||||||
if ( getVersion() < 400 ) {
|
if ( getVersion().isBefore( 4, 0 ) ) {
|
||||||
//precision of a Firebird 3 and earlier 'float(p)' represents
|
//precision of a Firebird 3 and earlier 'float(p)' represents
|
||||||
//decimal digits instead of binary digits
|
//decimal digits instead of binary digits
|
||||||
return super.getTypeName( code, binaryToDecimalPrecision( code, size ) );
|
return super.getTypeName( code, binaryToDecimalPrecision( code, size ) );
|
||||||
@ -217,7 +219,7 @@ public String getTypeName(int code, Size size) throws HibernateException {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFloatPrecision() {
|
public int getFloatPrecision() {
|
||||||
return getVersion() < 400
|
return getVersion().isBefore( 4, 0 )
|
||||||
? 21 // -> 7 decimal digits (actually 24, but needed for Dialect#binaryToDecimalPrecision(int,size))
|
? 21 // -> 7 decimal digits (actually 24, but needed for Dialect#binaryToDecimalPrecision(int,size))
|
||||||
: 24;
|
: 24;
|
||||||
}
|
}
|
||||||
@ -245,7 +247,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.cosh( queryEngine );
|
CommonFunctionFactory.cosh( queryEngine );
|
||||||
CommonFunctionFactory.sinh( queryEngine );
|
CommonFunctionFactory.sinh( queryEngine );
|
||||||
CommonFunctionFactory.tanh( queryEngine );
|
CommonFunctionFactory.tanh( queryEngine );
|
||||||
if ( getVersion() >= 300 ) {
|
if ( getVersion().isSince( 3, 0 ) ) {
|
||||||
CommonFunctionFactory.moreHyperbolic( queryEngine );
|
CommonFunctionFactory.moreHyperbolic( queryEngine );
|
||||||
CommonFunctionFactory.stddevPopSamp( queryEngine );
|
CommonFunctionFactory.stddevPopSamp( queryEngine );
|
||||||
CommonFunctionFactory.varPopSamp( queryEngine );
|
CommonFunctionFactory.varPopSamp( queryEngine );
|
||||||
@ -299,7 +301,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
doubleType
|
doubleType
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( getVersion() >= 400 ) {
|
if ( getVersion().isSince( 4, 0 ) ) {
|
||||||
Arrays.asList( "md5", "sha1", "sha256", "sha512" )
|
Arrays.asList( "md5", "sha1", "sha256", "sha512" )
|
||||||
.forEach( hash -> functionRegistry.registerPattern(
|
.forEach( hash -> functionRegistry.registerPattern(
|
||||||
hash,
|
hash,
|
||||||
@ -462,12 +464,12 @@ public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsTemporalLiteralOffset() {
|
public boolean supportsTemporalLiteralOffset() {
|
||||||
return getVersion() >= 400;
|
return getVersion().isSince( 4, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public int getDefaultDecimalPrecision() {
|
||||||
return getVersion() < 400 ? 18 : 38;
|
return getVersion().isBefore( 4, 0 ) ? 18 : 38;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -482,7 +484,7 @@ public String getNoColumnsInsertString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxAliasLength() {
|
public int getMaxAliasLength() {
|
||||||
return getVersion() < 400 ? 20 : 52;
|
return getVersion().isBefore( 4, 0 ) ? 20 : 52;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -499,8 +501,7 @@ public IdentifierHelper buildIdentifierHelper(
|
|||||||
// Additional reserved words
|
// Additional reserved words
|
||||||
// The Hibernate list of SQL:2003 reserved words doesn't contain all SQL:2003 reserved words,
|
// The Hibernate list of SQL:2003 reserved words doesn't contain all SQL:2003 reserved words,
|
||||||
// and Firebird is finicky when it comes to reserved words
|
// and Firebird is finicky when it comes to reserved words
|
||||||
int version = getVersion();
|
if ( version.isSince( 3, 0 ) ) {
|
||||||
if ( version >= 300 ) {
|
|
||||||
builder.applyReservedWords(
|
builder.applyReservedWords(
|
||||||
"AVG", "BOOLEAN", "CHARACTER_LENGTH", "CHAR_LENGTH", "CORR", "COUNT",
|
"AVG", "BOOLEAN", "CHARACTER_LENGTH", "CHAR_LENGTH", "CORR", "COUNT",
|
||||||
"COVAR_POP", "COVAR_SAMP", "EXTRACT", "LOWER", "MAX", "MIN", "OCTET_LENGTH", "POSITION",
|
"COVAR_POP", "COVAR_SAMP", "EXTRACT", "LOWER", "MAX", "MIN", "OCTET_LENGTH", "POSITION",
|
||||||
@ -540,7 +541,7 @@ public boolean qualifyIndexName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCommentOn() {
|
public boolean supportsCommentOn() {
|
||||||
return getVersion() >= 200;
|
return getVersion().isSince( 2, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -568,18 +569,18 @@ public int getInExpressionCountLimit() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsExistsInSelect() {
|
public boolean supportsExistsInSelect() {
|
||||||
return getVersion() >= 300;
|
return getVersion().isSince( 3, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPartitionBy() {
|
public boolean supportsPartitionBy() {
|
||||||
return getVersion() >= 300;
|
return getVersion().isSince( 3, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
||||||
//'boolean' type introduced in 3.0
|
//'boolean' type introduced in 3.0
|
||||||
if ( getVersion() < 300 ) {
|
if ( getVersion().isSince( 3, 0 ) ) {
|
||||||
appender.appendSql( bool ? '1' : '0' );
|
appender.appendSql( bool ? '1' : '0' );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -589,17 +590,17 @@ public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
return getVersion() < 300
|
return getVersion().isBefore( 3, 0 )
|
||||||
? super.getIdentityColumnSupport()
|
? super.getIdentityColumnSupport()
|
||||||
: new FirebirdIdentityColumnSupport();
|
: new FirebirdIdentityColumnSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
if ( getVersion() < 200 ) {
|
if ( getVersion().isBefore( 2, 0 ) ) {
|
||||||
return InterbaseSequenceSupport.INSTANCE;
|
return InterbaseSequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
else if ( getVersion() < 300 ) {
|
else if ( getVersion().isBefore( 3, 0 ) ) {
|
||||||
return FirebirdSequenceSupport.LEGACY_INSTANCE;
|
return FirebirdSequenceSupport.LEGACY_INSTANCE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -609,7 +610,7 @@ else if ( getVersion() < 300 ) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return getVersion() < 300
|
return getVersion().isBefore( 3, 0 )
|
||||||
? "select rdb$generator_name from rdb$generators"
|
? "select rdb$generator_name from rdb$generators"
|
||||||
// Note: Firebird 3 has an 'off by increment' bug (fixed in Firebird 4), see
|
// Note: Firebird 3 has an 'off by increment' bug (fixed in Firebird 4), see
|
||||||
// http://tracker.firebirdsql.org/browse/CORE-6084
|
// http://tracker.firebirdsql.org/browse/CORE-6084
|
||||||
@ -618,7 +619,7 @@ public String getQuerySequencesString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
||||||
return getVersion() < 300
|
return getVersion().isBefore( 3, 0 )
|
||||||
? SequenceNameExtractorImpl.INSTANCE
|
? SequenceNameExtractorImpl.INSTANCE
|
||||||
: SequenceInformationExtractorFirebirdDatabaseImpl.INSTANCE;
|
: SequenceInformationExtractorFirebirdDatabaseImpl.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -632,14 +633,14 @@ public String getForUpdateString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LimitHandler getLimitHandler() {
|
public LimitHandler getLimitHandler() {
|
||||||
return getVersion() < 300
|
return getVersion().isBefore( 3, 0 )
|
||||||
? SkipFirstLimitHandler.INSTANCE
|
? SkipFirstLimitHandler.INSTANCE
|
||||||
: OffsetFetchLimitHandler.INSTANCE;
|
: OffsetFetchLimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSelectGUIDString() {
|
public String getSelectGUIDString() {
|
||||||
return getVersion() < 210
|
return getVersion().isBefore( 2, 1 )
|
||||||
? super.getSelectGUIDString()
|
? super.getSelectGUIDString()
|
||||||
: "select uuid_to_char(gen_uuid()) from rdb$database";
|
: "select uuid_to_char(gen_uuid()) from rdb$database";
|
||||||
}
|
}
|
||||||
@ -674,12 +675,12 @@ public boolean isCurrentTimestampSelectStringCallable() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NullOrdering getNullOrdering() {
|
public NullOrdering getNullOrdering() {
|
||||||
return getVersion() >= 200 ? NullOrdering.SMALLEST : NullOrdering.LAST;
|
return getVersion().isSince( 2, 0 ) ? NullOrdering.SMALLEST : NullOrdering.LAST;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNullPrecedence() {
|
public boolean supportsNullPrecedence() {
|
||||||
return getVersion() >= 150;
|
return getVersion().isSince( 1, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -694,7 +695,7 @@ public boolean supportsValuesListForInsert() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsWindowFunctions() {
|
public boolean supportsWindowFunctions() {
|
||||||
return getVersion() >= 300;
|
return getVersion().isSince( 3, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -873,7 +874,7 @@ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext) {
|
public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext) {
|
||||||
return getVersion() < 210
|
return getVersion().isBefore( 2,1 )
|
||||||
? super.getFallbackSqmMutationStrategy( entityDescriptor, runtimeModelCreationContext )
|
? super.getFallbackSqmMutationStrategy( entityDescriptor, runtimeModelCreationContext )
|
||||||
: new GlobalTemporaryTableMutationStrategy(
|
: new GlobalTemporaryTableMutationStrategy(
|
||||||
TemporaryTable.createIdTable(
|
TemporaryTable.createIdTable(
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.Replacer;
|
import org.hibernate.dialect.Replacer;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
@ -68,24 +69,24 @@
|
|||||||
*/
|
*/
|
||||||
public class InformixDialect extends Dialect {
|
public class InformixDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
private final UniqueDelegate uniqueDelegate;
|
private final UniqueDelegate uniqueDelegate;
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
public InformixDialect(DialectResolutionInfo info) {
|
public InformixDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public InformixDialect() {
|
public InformixDialect() {
|
||||||
this( 7 );
|
this( DatabaseVersion.make( 7, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new <code>InformixDialect</code> instance. Sets up the JDBC /
|
* Creates new <code>InformixDialect</code> instance. Sets up the JDBC /
|
||||||
* Informix type mappings.
|
* Informix type mappings.
|
||||||
*/
|
*/
|
||||||
public InformixDialect(int version) {
|
public InformixDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
@ -111,16 +112,16 @@ public InformixDialect(int version) {
|
|||||||
|
|
||||||
uniqueDelegate = new InformixUniqueDelegate( this );
|
uniqueDelegate = new InformixUniqueDelegate( this );
|
||||||
|
|
||||||
limitHandler = getVersion() < 10
|
limitHandler = getVersion().isBefore( 10 )
|
||||||
? FirstLimitHandler.INSTANCE
|
? FirstLimitHandler.INSTANCE
|
||||||
//according to the Informix documentation for
|
//according to the Informix documentation for
|
||||||
//version 11 and above, parameters are supported
|
//version 11 and above, parameters are supported
|
||||||
//but I have not tested this at all!
|
//but I have not tested this at all!
|
||||||
: new SkipFirstLimitHandler( getVersion() >= 11 );
|
: new SkipFirstLimitHandler( getVersion().isSince( 11 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,16 +6,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.community.dialect.identity.Ingres10IdentityColumnSupport;
|
||||||
|
import org.hibernate.community.dialect.identity.Ingres9IdentityColumnSupport;
|
||||||
|
import org.hibernate.community.dialect.pagination.FirstLimitHandler;
|
||||||
|
import org.hibernate.community.dialect.pagination.IngresLimitHandler;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.MySQLDialect;
|
import org.hibernate.dialect.MySQLDialect;
|
||||||
import org.hibernate.dialect.TimeZoneSupport;
|
import org.hibernate.dialect.TimeZoneSupport;
|
||||||
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.community.dialect.identity.Ingres10IdentityColumnSupport;
|
|
||||||
import org.hibernate.community.dialect.identity.Ingres9IdentityColumnSupport;
|
|
||||||
import org.hibernate.community.dialect.pagination.FirstLimitHandler;
|
|
||||||
import org.hibernate.community.dialect.pagination.IngresLimitHandler;
|
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.sequence.ANSISequenceSupport;
|
import org.hibernate.dialect.sequence.ANSISequenceSupport;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
@ -57,7 +60,6 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.Types;
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,27 +90,27 @@ public class IngresDialect extends Dialect {
|
|||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private final SequenceSupport sequenceSupport;
|
private final SequenceSupport sequenceSupport;
|
||||||
|
|
||||||
public IngresDialect(DialectResolutionInfo info) {
|
public IngresDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public IngresDialect() {
|
public IngresDialect() {
|
||||||
this(920);
|
this( DatabaseVersion.make( 9, 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a IngresDialect
|
* Constructs a IngresDialect
|
||||||
*/
|
*/
|
||||||
public IngresDialect(int version) {
|
public IngresDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
if ( getVersion() < 1000 ) {
|
if ( version.isBefore( 10 ) ) {
|
||||||
registerColumnType( Types.BOOLEAN, "tinyint" );
|
registerColumnType( Types.BOOLEAN, "tinyint" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -138,7 +140,7 @@ public IngresDialect(int version) {
|
|||||||
//note: 'long nvarchar' is a synonym for 'nclob'
|
//note: 'long nvarchar' is a synonym for 'nclob'
|
||||||
registerColumnType( Types.NVARCHAR, "long nvarchar($l)" );
|
registerColumnType( Types.NVARCHAR, "long nvarchar($l)" );
|
||||||
|
|
||||||
if ( getVersion() >= 930 ) {
|
if ( getVersion().isSince( 9, 3 ) ) {
|
||||||
// Not completely necessary, given that Ingres
|
// Not completely necessary, given that Ingres
|
||||||
// can be configured to set DATE = ANSIDATE
|
// can be configured to set DATE = ANSIDATE
|
||||||
registerColumnType( Types.DATE, "ansidate" );
|
registerColumnType( Types.DATE, "ansidate" );
|
||||||
@ -156,25 +158,25 @@ public IngresDialect(int version) {
|
|||||||
// 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" );
|
getDefaultProperties().setProperty( Environment.USE_GET_GENERATED_KEYS, "false" );
|
||||||
|
|
||||||
if ( getVersion() < 1000 ) {
|
if ( getVersion().isBefore( 10 ) ) {
|
||||||
// There is no support for a native boolean type that accepts values
|
// There is no support for a native boolean type that accepts values
|
||||||
// of true, false or unknown. Using the tinyint type requires
|
// of true, false or unknown. Using the tinyint type requires
|
||||||
// substitutions of true and false.
|
// substitutions of true and false.
|
||||||
getDefaultProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, "true=1,false=0" );
|
getDefaultProperties().setProperty( Environment.QUERY_SUBSTITUTIONS, "true=1,false=0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
limitHandler = getVersion() < 930 ? FirstLimitHandler.INSTANCE : IngresLimitHandler.INSTANCE;
|
limitHandler = getVersion().isBefore( 9, 3 ) ? FirstLimitHandler.INSTANCE : IngresLimitHandler.INSTANCE;
|
||||||
|
|
||||||
sequenceSupport = new ANSISequenceSupport() {
|
sequenceSupport = new ANSISequenceSupport() {
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPooledSequences() {
|
public boolean supportsPooledSequences() {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,12 +201,12 @@ public JdbcType resolveSqlTypeDescriptor(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return getVersion() < 1000 ? Types.BIT : Types.BOOLEAN;
|
return getVersion().isBefore( 10 ) ? Types.BIT : Types.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
||||||
if ( getVersion() < 1000 ) {
|
if ( getVersion().isBefore( 10 ) ) {
|
||||||
appender.appendSql( bool ? '1' : '0' );
|
appender.appendSql( bool ? '1' : '0' );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -351,7 +353,7 @@ public SequenceSupport getSequenceSupport() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return getVersion() < 930
|
return getVersion().isBefore( 9, 3 )
|
||||||
? "select seq_name from iisequence"
|
? "select seq_name from iisequence"
|
||||||
: "select seq_name from iisequences";
|
: "select seq_name from iisequences";
|
||||||
}
|
}
|
||||||
@ -373,10 +375,10 @@ public LimitHandler getLimitHandler() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
if ( getVersion() >= 1000 ) {
|
if ( getVersion().isSince( 10 ) ) {
|
||||||
return new Ingres10IdentityColumnSupport();
|
return new Ingres10IdentityColumnSupport();
|
||||||
}
|
}
|
||||||
else if (getVersion() >= 930) {
|
else if ( getVersion().isSince( 9, 3 ) ) {
|
||||||
return new Ingres9IdentityColumnSupport();
|
return new Ingres9IdentityColumnSupport();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -406,7 +408,7 @@ public boolean isCurrentTimestampSelectStringCallable() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCurrentTimestampSelection() {
|
public boolean supportsCurrentTimestampSelection() {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -458,7 +460,7 @@ public String getTemporaryTableCreateCommand() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsUnionAll() {
|
public boolean supportsUnionAll() {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -470,7 +472,7 @@ public boolean supportsUnionInSubquery() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsSubqueryInSelect() {
|
public boolean supportsSubqueryInSelect() {
|
||||||
// At least according to HHH-4961
|
// At least according to HHH-4961
|
||||||
return getVersion() >= 1000;
|
return getVersion().isSince( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -483,12 +485,12 @@ public boolean supportsOrderByInSubquery() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesReadCommittedCauseWritersToBlockReaders() {
|
public boolean doesReadCommittedCauseWritersToBlockReaders() {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
|
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -526,6 +528,6 @@ public String translateExtractField(TemporalUnit unit) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsFetchClause(FetchClauseType type) {
|
public boolean supportsFetchClause(FetchClauseType type) {
|
||||||
return getVersion() >= 930;
|
return getVersion().isSince( 9, 3 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,14 +6,19 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport;
|
||||||
|
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorSAPDBDatabaseImpl;
|
||||||
import org.hibernate.dialect.AbstractTransactSQLDialect;
|
import org.hibernate.dialect.AbstractTransactSQLDialect;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
|
import org.hibernate.dialect.pagination.LimitOffsetLimitHandler;
|
||||||
import org.hibernate.community.dialect.sequence.MaxDBSequenceSupport;
|
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
@ -27,15 +32,13 @@
|
|||||||
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.spi.StandardSqlAstTranslatorFactory;
|
||||||
import org.hibernate.sql.ast.tree.Statement;
|
import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorSAPDBDatabaseImpl;
|
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
import org.hibernate.type.descriptor.jdbc.JdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.DatabaseMetaData;
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SQL dialect compatible with SAP MaxDB.
|
* A SQL dialect compatible with SAP MaxDB.
|
||||||
@ -94,8 +97,8 @@ public MaxDBDialect(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,17 +6,20 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
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.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.SequenceInformationExtractorMimerSQLDatabaseImpl;
|
import org.hibernate.community.dialect.sequence.SequenceInformationExtractorMimerSQLDatabaseImpl;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
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.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
||||||
import org.hibernate.community.dialect.sequence.MimerSequenceSupport;
|
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
@ -33,10 +36,10 @@
|
|||||||
import org.hibernate.sql.exec.spi.JdbcOperation;
|
import org.hibernate.sql.exec.spi.JdbcOperation;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialect for Mimer SQL 11.
|
* A dialect for Mimer SQL 11.
|
||||||
*
|
*
|
||||||
@ -99,8 +102,8 @@ public String getTypeName(int code, Size size) throws HibernateException {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,15 +6,25 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.community.dialect;
|
package org.hibernate.community.dialect;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
import org.hibernate.community.dialect.sequence.RDMSSequenceSupport;
|
||||||
import org.hibernate.dialect.AbstractTransactSQLDialect;
|
import org.hibernate.dialect.AbstractTransactSQLDialect;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.OracleDialect;
|
import org.hibernate.dialect.OracleDialect;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
import org.hibernate.dialect.lock.*;
|
import org.hibernate.dialect.lock.LockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.OptimisticForceIncrementLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.OptimisticLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticForceIncrementLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticReadUpdateLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticWriteUpdateLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.SelectLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.UpdateLockingStrategy;
|
||||||
import org.hibernate.dialect.pagination.FetchLimitHandler;
|
import org.hibernate.dialect.pagination.FetchLimitHandler;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
import org.hibernate.community.dialect.sequence.RDMSSequenceSupport;
|
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
@ -35,9 +45,10 @@
|
|||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import java.sql.Types;
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS).
|
* This is the Hibernate dialect for the Unisys 2200 Relational Database (RDMS).
|
||||||
* This dialect was developed for use with Hibernate 3.0.5. Other versions may
|
* This dialect was developed for use with Hibernate 3.0.5. Other versions may
|
||||||
@ -114,8 +125,8 @@ public RDMSOS2200Dialect(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,12 +12,11 @@
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.hibernate.ScrollMode;
|
import org.hibernate.ScrollMode;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.community.dialect.identity.SQLiteIdentityColumnSupport;
|
import org.hibernate.community.dialect.identity.SQLiteIdentityColumnSupport;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.NationalizationSupport;
|
import org.hibernate.dialect.NationalizationSupport;
|
||||||
import org.hibernate.dialect.Replacer;
|
import org.hibernate.dialect.Replacer;
|
||||||
@ -59,6 +58,8 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ClobJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
import static org.hibernate.query.TemporalUnit.DAY;
|
import static org.hibernate.query.TemporalUnit.DAY;
|
||||||
import static org.hibernate.query.TemporalUnit.EPOCH;
|
import static org.hibernate.query.TemporalUnit.EPOCH;
|
||||||
@ -80,22 +81,22 @@ public class SQLiteDialect extends Dialect {
|
|||||||
private static final SQLiteIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new SQLiteIdentityColumnSupport();
|
private static final SQLiteIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new SQLiteIdentityColumnSupport();
|
||||||
|
|
||||||
private final UniqueDelegate uniqueDelegate;
|
private final UniqueDelegate uniqueDelegate;
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
public SQLiteDialect(DialectResolutionInfo info) {
|
public SQLiteDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteDialect() {
|
public SQLiteDialect() {
|
||||||
this( 200 );
|
this( DatabaseVersion.make( 2, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLiteDialect(int version) {
|
public SQLiteDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
if ( version < 300 ) {
|
if ( version.isBefore( 3 ) ) {
|
||||||
registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
|
registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
|
||||||
registerColumnType( Types.CHAR, "char" );
|
registerColumnType( Types.CHAR, "char" );
|
||||||
registerColumnType( Types.NCHAR, "nchar" );
|
registerColumnType( Types.NCHAR, "nchar" );
|
||||||
@ -128,7 +129,7 @@ public UniqueDelegate getUniqueDelegate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +359,7 @@ public boolean supportsOuterJoinForUpdate() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNullPrecedence() {
|
public boolean supportsNullPrecedence() {
|
||||||
return getVersion() >= 330;
|
return getVersion().isSince( 3, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
import org.hibernate.boot.model.relational.QualifiedTableName;
|
import org.hibernate.boot.model.relational.QualifiedTableName;
|
||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
@ -70,20 +71,20 @@
|
|||||||
*/
|
*/
|
||||||
public class TeradataDialect extends Dialect {
|
public class TeradataDialect extends Dialect {
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
|
private static final int PARAM_LIST_SIZE_LIMIT = 1024;
|
||||||
|
|
||||||
public TeradataDialect(DialectResolutionInfo info) {
|
public TeradataDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeradataDialect() {
|
public TeradataDialect() {
|
||||||
this(12);
|
this( DatabaseVersion.make( 12, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public TeradataDialect(int version) {
|
public TeradataDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ public TeradataDialect(int version) {
|
|||||||
registerColumnType( Types.BINARY, "byte($l)" );
|
registerColumnType( Types.BINARY, "byte($l)" );
|
||||||
registerColumnType( Types.VARBINARY, "varbyte($l)" );
|
registerColumnType( Types.VARBINARY, "varbyte($l)" );
|
||||||
|
|
||||||
if ( getVersion() < 13 ) {
|
if ( getVersion().isBefore( 13 ) ) {
|
||||||
registerColumnType( Types.BIGINT, "numeric(19,0)" );
|
registerColumnType( Types.BIGINT, "numeric(19,0)" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -115,7 +116,7 @@ public TeradataDialect(int version) {
|
|||||||
registerKeyword( "account" );
|
registerKeyword( "account" );
|
||||||
registerKeyword( "class" );
|
registerKeyword( "class" );
|
||||||
|
|
||||||
if ( getVersion() < 14 ) {
|
if ( getVersion().isBefore( 14 ) ) {
|
||||||
// use getBytes instead of getBinaryStream
|
// use getBytes instead of getBinaryStream
|
||||||
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
|
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "false" );
|
||||||
// no batch statements
|
// no batch statements
|
||||||
@ -164,7 +165,7 @@ protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +176,7 @@ public int getPreferredSqlTypeCodeForBoolean() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public int getDefaultDecimalPrecision() {
|
||||||
return getVersion() < 14 ? 18 : 38;
|
return getVersion().isBefore( 14 ) ? 18 : 38;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -257,7 +258,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
.setExactArgumentCount( 2 )
|
.setExactArgumentCount( 2 )
|
||||||
.register();
|
.register();
|
||||||
|
|
||||||
if ( getVersion() >= 14 ) {
|
if ( getVersion().isSince( 14 ) ) {
|
||||||
|
|
||||||
//list actually taken from Teradata 15 docs
|
//list actually taken from Teradata 15 docs
|
||||||
CommonFunctionFactory.lastDay( queryEngine );
|
CommonFunctionFactory.lastDay( queryEngine );
|
||||||
@ -288,7 +289,7 @@ public String getForUpdateString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAddColumnString() {
|
public String getAddColumnString() {
|
||||||
return getVersion() < 14 ? super.getAddColumnString() : "add";
|
return getVersion().isBefore( 14 ) ? super.getAddColumnString() : "add";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -468,7 +469,7 @@ public ResultSet getResultSet(CallableStatement cs) throws SQLException {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
||||||
return getVersion() < 14 ? super.getViolatedConstraintNameExtractor() : EXTRACTOR;
|
return getVersion().isBefore( 14 ) ? super.getViolatedConstraintNameExtractor() : EXTRACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ViolatedConstraintNameExtractor EXTRACTOR =
|
private static ViolatedConstraintNameExtractor EXTRACTOR =
|
||||||
@ -514,12 +515,12 @@ public boolean supportsWait() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean useFollowOnLocking(String sql, QueryOptions queryOptions) {
|
public boolean useFollowOnLocking(String sql, QueryOptions queryOptions) {
|
||||||
return getVersion() >= 14;
|
return getVersion().isSince( 14 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWriteLockString(int timeout) {
|
public String getWriteLockString(int timeout) {
|
||||||
if ( getVersion() < 14 ) {
|
if ( getVersion().isBefore( 14 ) ) {
|
||||||
return super.getWriteLockString( timeout );
|
return super.getWriteLockString( timeout );
|
||||||
}
|
}
|
||||||
String sMsg = " Locking row for write ";
|
String sMsg = " Locking row for write ";
|
||||||
@ -531,7 +532,7 @@ public String getWriteLockString(int timeout) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getReadLockString(int timeout) {
|
public String getReadLockString(int timeout) {
|
||||||
if ( getVersion() < 14 ) {
|
if ( getVersion().isBefore( 14 ) ) {
|
||||||
return super.getReadLockString( timeout );
|
return super.getReadLockString( timeout );
|
||||||
}
|
}
|
||||||
String sMsg = " Locking row for read ";
|
String sMsg = " Locking row for read ";
|
||||||
@ -592,14 +593,14 @@ public String[] getSqlCreateStrings(Index index, Metadata metadata, SqlStringGen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
return getVersion() < 14
|
return getVersion().isBefore( 14 )
|
||||||
? super.getIdentityColumnSupport()
|
? super.getIdentityColumnSupport()
|
||||||
: new Teradata14IdentityColumnSupport();
|
: new Teradata14IdentityColumnSupport();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
|
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
|
||||||
return getVersion() < 14
|
return getVersion().isBefore( 14 )
|
||||||
? super.applyLocksToSql( sql, aliasedLockOptions, keyColumnNames )
|
? super.applyLocksToSql( sql, aliasedLockOptions, keyColumnNames )
|
||||||
: new ForUpdateFragment( this, aliasedLockOptions, keyColumnNames ).toFragmentString() + " " + sql;
|
: new ForUpdateFragment( this, aliasedLockOptions, keyColumnNames ).toFragmentString() + " " + sql;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
|
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;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
@ -45,6 +46,8 @@
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A SQL dialect for TimesTen 5.1.
|
* A SQL dialect for TimesTen 5.1.
|
||||||
* <p/>
|
* <p/>
|
||||||
@ -103,8 +106,8 @@ public TimesTenDialect(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -6,6 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
@ -41,16 +51,6 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.DatabaseMetaData;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.TimeZone;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.query.TemporalUnit.DAY;
|
import static org.hibernate.query.TemporalUnit.DAY;
|
||||||
@ -70,27 +70,24 @@ public class CockroachDialect extends Dialect {
|
|||||||
|
|
||||||
// * no support for java.sql.Clob
|
// * no support for java.sql.Clob
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
private final PostgreSQLDriverKind driverKind;
|
private final PostgreSQLDriverKind driverKind;
|
||||||
|
|
||||||
public CockroachDialect() {
|
public CockroachDialect() {
|
||||||
this( 1920 );
|
this( DatabaseVersion.make( 19, 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CockroachDialect(DialectResolutionInfo info) {
|
public CockroachDialect(DialectResolutionInfo info) {
|
||||||
this(
|
this( info.makeCopy(), PostgreSQLDriverKind.determineKind( info ) );
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
|
||||||
PostgreSQLDriverKind.determineKind( info )
|
|
||||||
);
|
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CockroachDialect(int version) {
|
public CockroachDialect(DatabaseVersion version) {
|
||||||
// Assume PgJDBC by default
|
// Assume PgJDBC by default
|
||||||
this( version, PostgreSQLDriverKind.PG_JDBC );
|
this( version, PostgreSQLDriverKind.PG_JDBC );
|
||||||
}
|
}
|
||||||
|
|
||||||
public CockroachDialect(int version, PostgreSQLDriverKind driverKind) {
|
public CockroachDialect(DatabaseVersion version, PostgreSQLDriverKind driverKind) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this.version = version;
|
this.version = version;
|
||||||
@ -118,7 +115,7 @@ public CockroachDialect(int version, PostgreSQLDriverKind driverKind) {
|
|||||||
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($s)" );
|
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($s)" );
|
||||||
|
|
||||||
// Prefer jsonb if possible
|
// Prefer jsonb if possible
|
||||||
if ( getVersion() >= 2000 ) {
|
if ( getVersion().isSince( 20, 0 ) ) {
|
||||||
registerColumnType( SqlTypes.INET, "inet" );
|
registerColumnType( SqlTypes.INET, "inet" );
|
||||||
registerColumnType( SqlTypes.JSON, "jsonb" );
|
registerColumnType( SqlTypes.JSON, "jsonb" );
|
||||||
}
|
}
|
||||||
@ -132,12 +129,11 @@ public CockroachDialect(int version, PostgreSQLDriverKind driverKind) {
|
|||||||
@Override
|
@Override
|
||||||
public String getTypeName(int code, Size size) throws HibernateException {
|
public String getTypeName(int code, Size size) throws HibernateException {
|
||||||
// The maximum scale for `interval second` is 6 unfortunately so we have to use numeric by default
|
// The maximum scale for `interval second` is 6 unfortunately so we have to use numeric by default
|
||||||
switch ( code ) {
|
if ( code == SqlTypes.INTERVAL_SECOND ) {
|
||||||
case SqlTypes.INTERVAL_SECOND:
|
final Integer scale = size.getScale();
|
||||||
final Integer scale = size.getScale();
|
if ( scale == null || scale > 6 ) {
|
||||||
if ( scale == null || scale > 6 ) {
|
return getTypeName( SqlTypes.NUMERIC, size );
|
||||||
return getTypeName( SqlTypes.NUMERIC, size );
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.getTypeName( code, size );
|
return super.getTypeName( code, size );
|
||||||
}
|
}
|
||||||
@ -180,7 +176,7 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLIntervalSecondJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLIntervalSecondJdbcType.INSTANCE );
|
||||||
|
|
||||||
if ( getVersion() >= 2000 ) {
|
if ( getVersion().isSince( 20, 0 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLInetJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLInetJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLJsonbJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLJsonbJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
@ -191,7 +187,7 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +537,7 @@ public String getForUpdateString(String aliases) {
|
|||||||
@Override
|
@Override
|
||||||
public String getForUpdateString(LockOptions lockOptions) {
|
public String getForUpdateString(LockOptions lockOptions) {
|
||||||
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
||||||
if ( getVersion() < 2010 ) {
|
if ( getVersion().isBefore( 20, 1 ) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return super.getForUpdateString( lockOptions );
|
return super.getForUpdateString( lockOptions );
|
||||||
@ -550,7 +546,7 @@ public String getForUpdateString(LockOptions lockOptions) {
|
|||||||
@Override
|
@Override
|
||||||
public String getForUpdateString(String aliases, LockOptions lockOptions) {
|
public String getForUpdateString(String aliases, LockOptions lockOptions) {
|
||||||
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
||||||
if ( getVersion() < 2010 ) {
|
if ( getVersion().isBefore( 20, 1 ) ) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -668,7 +664,7 @@ public boolean supportsWindowFunctions() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getVersion() >= 2010;
|
return getVersion().isSince( 20, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -678,12 +674,12 @@ public boolean supportsWait() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
return getVersion() >= 2010;
|
return getVersion().isSince( 20, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RowLockStrategy getWriteRowLockStrategy() {
|
public RowLockStrategy getWriteRowLockStrategy() {
|
||||||
return getVersion() >= 2010 ? RowLockStrategy.TABLE : RowLockStrategy.NONE;
|
return getVersion().isSince( 20, 1 ) ? RowLockStrategy.TABLE : RowLockStrategy.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -51,7 +51,7 @@ protected LockStrategy determineLockingStrategy(
|
|||||||
ForUpdateClause forUpdateClause,
|
ForUpdateClause forUpdateClause,
|
||||||
Boolean followOnLocking) {
|
Boolean followOnLocking) {
|
||||||
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
||||||
if ( getDialect().getVersion() < 2010 ) {
|
if ( getDialect().getVersion().isBefore( 20, 1 ) ) {
|
||||||
return LockStrategy.NONE;
|
return LockStrategy.NONE;
|
||||||
}
|
}
|
||||||
return super.determineLockingStrategy( querySpec, forUpdateClause, followOnLocking );
|
return super.determineLockingStrategy( querySpec, forUpdateClause, followOnLocking );
|
||||||
@ -60,7 +60,7 @@ protected LockStrategy determineLockingStrategy(
|
|||||||
@Override
|
@Override
|
||||||
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
||||||
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
// Support was added in 20.1: https://www.cockroachlabs.com/docs/v20.1/select-for-update.html
|
||||||
if ( getDialect().getVersion() < 2010 ) {
|
if ( getDialect().getVersion().isBefore( 20, 1 ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.renderForUpdateClause( querySpec, forUpdateClause );
|
super.renderForUpdateClause( querySpec, forUpdateClause );
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
public class DB297Dialect extends DB2Dialect {
|
public class DB297Dialect extends DB2Dialect {
|
||||||
|
|
||||||
public DB297Dialect() {
|
public DB297Dialect() {
|
||||||
super( 970 );
|
super( DatabaseVersion.make( 9, 7 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,21 +75,21 @@ public class DB2Dialect extends Dialect {
|
|||||||
private static final String FOR_SHARE_SKIP_LOCKED_SQL = FOR_SHARE_SQL + SKIP_LOCKED_SQL;
|
private static final String FOR_SHARE_SKIP_LOCKED_SQL = FOR_SHARE_SQL + SKIP_LOCKED_SQL;
|
||||||
private static final String FOR_UPDATE_SKIP_LOCKED_SQL = FOR_UPDATE_SQL + SKIP_LOCKED_SQL;
|
private static final String FOR_UPDATE_SKIP_LOCKED_SQL = FOR_UPDATE_SQL + SKIP_LOCKED_SQL;
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
private final UniqueDelegate uniqueDelegate;
|
private final UniqueDelegate uniqueDelegate;
|
||||||
|
|
||||||
public DB2Dialect(DialectResolutionInfo info) {
|
public DB2Dialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DB2Dialect() {
|
public DB2Dialect() {
|
||||||
this( 900 );
|
this( DatabaseVersion.make( 9, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DB2Dialect(int version) {
|
public DB2Dialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ public DB2Dialect(int version) {
|
|||||||
// registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
|
// registerColumnType( Types.DECIMAL, "decimal($p,$s)" );
|
||||||
registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
|
registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
|
||||||
|
|
||||||
if ( getVersion() < 1100 ) {
|
if ( getVersion().isBefore( 11 ) ) {
|
||||||
registerColumnType( Types.BINARY, "varchar($l) for bit data" ); //should use 'binary' since version 11
|
registerColumnType( Types.BINARY, "varchar($l) for bit data" ); //should use 'binary' since version 11
|
||||||
registerColumnType( Types.BINARY, 254, "char($l) for bit data" ); //should use 'binary' since version 11
|
registerColumnType( Types.BINARY, 254, "char($l) for bit data" ); //should use 'binary' since version 11
|
||||||
registerColumnType( Types.VARBINARY, "varchar($l) for bit data" ); //should use 'varbinary' since version 11
|
registerColumnType( Types.VARBINARY, "varchar($l) for bit data" ); //should use 'varbinary' since version 11
|
||||||
@ -134,7 +134,7 @@ public DB2Dialect(int version) {
|
|||||||
|
|
||||||
uniqueDelegate = createUniqueDelegate();
|
uniqueDelegate = createUniqueDelegate();
|
||||||
|
|
||||||
limitHandler = getVersion() < 1110
|
limitHandler = getVersion().isBefore( 11, 1 )
|
||||||
? LegacyDB2LimitHandler.INSTANCE
|
? LegacyDB2LimitHandler.INSTANCE
|
||||||
: DB2LimitHandler.INSTANCE;
|
: DB2LimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -144,14 +144,14 @@ protected UniqueDelegate createUniqueDelegate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDefaultDecimalPrecision() {
|
public DatabaseVersion getVersion() {
|
||||||
//this is the maximum allowed in DB2
|
return version;
|
||||||
return 31;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public int getDefaultDecimalPrecision() {
|
||||||
return version;
|
//this is the maximum allowed in DB2
|
||||||
|
return 31;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -338,7 +338,7 @@ public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLowercaseFunction() {
|
public String getLowercaseFunction() {
|
||||||
return getVersion() < 970 ? "lcase" : super.getLowercaseFunction();
|
return getVersion().isBefore( 9, 7 ) ? "lcase" : super.getLowercaseFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -348,7 +348,7 @@ public boolean dropConstraints() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
return getVersion() < 970
|
return getVersion().isBefore( 9, 7 )
|
||||||
? LegacyDB2SequenceSupport.INSTANCE
|
? LegacyDB2SequenceSupport.INSTANCE
|
||||||
: DB2SequenceSupport.INSTANCE;
|
: DB2SequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -376,7 +376,7 @@ public String getForUpdateString() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
// Introduced in 11.5: https://www.ibm.com/docs/en/db2/11.5?topic=statement-concurrent-access-resolution-clause
|
// Introduced in 11.5: https://www.ibm.com/docs/en/db2/11.5?topic=statement-concurrent-access-resolution-clause
|
||||||
return getVersion() >= 1150;
|
return getVersion().isSince( 11, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -531,15 +531,13 @@ public boolean supportsTupleDistinctCounts() {
|
|||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
|
||||||
final int version = getVersion();
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration().getJdbcTypeDescriptorRegistry();
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
|
||||||
.getJdbcTypeDescriptorRegistry();
|
|
||||||
|
|
||||||
if ( version < 1100 ) {
|
if ( version.isBefore( 11 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
||||||
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
// Binary literals were only added in 11. See https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.sql.ref.doc/doc/r0000731.html#d79816e393
|
||||||
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
jdbcTypeRegistry.addDescriptor( Types.VARBINARY, VarbinaryJdbcType.INSTANCE_WITHOUT_LITERALS );
|
||||||
if ( version < 970 ) {
|
if ( version.isBefore( 9, 7 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -672,7 +670,7 @@ public String translateExtractField(TemporalUnit unit) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
||||||
if ( getVersion() < 1100 ) {
|
if ( getVersion().isBefore( 11 ) ) {
|
||||||
appender.appendSql( bool ? '1' : '0' );
|
appender.appendSql( bool ? '1' : '0' );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.hibernate.query.FetchClauseType;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.query.ComparisonOperator;
|
import org.hibernate.query.ComparisonOperator;
|
||||||
|
import org.hibernate.query.FetchClauseType;
|
||||||
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
||||||
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||||
@ -51,7 +51,7 @@ protected void renderExpressionAsClauseItem(Expression expression) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) {
|
public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanExpressionPredicate) {
|
||||||
if ( getDialect().getVersion() >= 1100 ) {
|
if ( getDialect().getVersion().isSince( 11 ) ) {
|
||||||
booleanExpressionPredicate.getExpression().accept( this );
|
booleanExpressionPredicate.getExpression().accept( this );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -132,12 +132,12 @@ protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
|
|||||||
// Check if current query part is already row numbering to avoid infinite recursion
|
// Check if current query part is already row numbering to avoid infinite recursion
|
||||||
return getQueryPartForRowNumbering() != queryPart && (
|
return getQueryPartForRowNumbering() != queryPart && (
|
||||||
useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart )
|
useOffsetFetchClause( queryPart ) && !isRowsOnlyFetchClauseType( queryPart )
|
||||||
|| getDialect().getVersion() < 1110 && ( queryPart.isRoot() && hasLimit() || !( queryPart.getFetchClauseExpression() instanceof Literal ) )
|
|| getDialect().getVersion().isBefore( 11, 1 ) && ( queryPart.isRoot() && hasLimit() || !( queryPart.getFetchClauseExpression() instanceof Literal ) )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean supportsOffsetClause() {
|
protected boolean supportsOffsetClause() {
|
||||||
return getDialect().getVersion() >= 1110;
|
return getDialect().getVersion().isSince( 11, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -228,7 +228,7 @@ protected boolean renderReturningClause(MutationStatement statement) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
|
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
|
||||||
if ( getDialect().getVersion() >= 1110 ) {
|
if ( getDialect().getVersion().isSince( 11, 1 ) ) {
|
||||||
renderComparisonStandard( lhs, operator, rhs );
|
renderComparisonStandard( lhs, operator, rhs );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -9,8 +9,7 @@
|
|||||||
/**
|
/**
|
||||||
* Details about the underlying database, as understood by a Dialect.
|
* Details about the underlying database, as understood by a Dialect.
|
||||||
*
|
*
|
||||||
* Also used in conjunction with {@link org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo}
|
* @see org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo
|
||||||
* to help resolve the Dialect to use.
|
|
||||||
*/
|
*/
|
||||||
public interface DatabaseVersion {
|
public interface DatabaseVersion {
|
||||||
/**
|
/**
|
||||||
@ -18,6 +17,27 @@ public interface DatabaseVersion {
|
|||||||
*/
|
*/
|
||||||
int NO_VERSION = -9999;
|
int NO_VERSION = -9999;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for DatabaseVersion based on major version (minor and micro set to zero)
|
||||||
|
*/
|
||||||
|
static DatabaseVersion make(Integer major) {
|
||||||
|
return make( major, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for DatabaseVersion based on major and minor version (micro set to zero)
|
||||||
|
*/
|
||||||
|
static DatabaseVersion make(Integer major, Integer minor) {
|
||||||
|
return make( major, minor, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for DatabaseVersion based on major, minor and micro
|
||||||
|
*/
|
||||||
|
static DatabaseVersion make(Integer major, Integer minor, Integer micro) {
|
||||||
|
return new SimpleDatabaseVersion( major, minor, micro );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Obtain access to the database major version, as returned from
|
* Obtain access to the database major version, as returned from
|
||||||
* {@link java.sql.DatabaseMetaData#getDatabaseMajorVersion()} for the target database.
|
* {@link java.sql.DatabaseMetaData#getDatabaseMajorVersion()} for the target database.
|
||||||
@ -39,28 +59,195 @@ public interface DatabaseVersion {
|
|||||||
int getDatabaseMinorVersion();
|
int getDatabaseMinorVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a simple int representing the version based on the formula
|
* Obtain access to the database minor version, as returned from
|
||||||
* {@code ({major) * 10000}) + (minor * 1000)} where minor == {@link #NO_VERSION}
|
* {@link java.sql.DatabaseMetaData#getDatabaseMinorVersion()} for the target database.
|
||||||
* is normalized to zero
|
*
|
||||||
|
* @return The database minor version, or {@value #NO_VERSION} to indicate "no version information"
|
||||||
|
* @see java.sql.DatabaseMetaData#getDatabaseMinorVersion()
|
||||||
*/
|
*/
|
||||||
default int getCanonicalVersion() {
|
default int getDatabaseMicroVersion() {
|
||||||
final int major = getDatabaseMajorVersion();
|
return 0;
|
||||||
final int minor = getDatabaseMinorVersion() == NO_VERSION
|
|
||||||
? 0
|
|
||||||
: getDatabaseMinorVersion();
|
|
||||||
return ( major * 10000 ) + ( minor * 1000 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a simple copy of this version object
|
||||||
|
*/
|
||||||
|
default DatabaseVersion makeCopy() {
|
||||||
|
return new SimpleDatabaseVersion( this );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Make a copy of this version object, possibly converting {@link #NO_VERSION}
|
||||||
|
* to zero
|
||||||
|
*/
|
||||||
|
default DatabaseVersion makeCopy(boolean noVersionAsZero) {
|
||||||
|
return new SimpleDatabaseVersion( this, noVersionAsZero );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the versions are the same/equal.
|
||||||
|
*/
|
||||||
|
default boolean isSame(DatabaseVersion other) {
|
||||||
|
return isSame( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion(), other.getDatabaseMicroVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this version matches the passed one.
|
||||||
|
*/
|
||||||
|
default boolean isSame(int otherMajor) {
|
||||||
|
return getDatabaseMajorVersion() == otherMajor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this version matches the passed one.
|
||||||
|
*/
|
||||||
|
default boolean isSame(int otherMajor, int otherMinor) {
|
||||||
|
return isSame( otherMajor ) && getDatabaseMinorVersion() == otherMinor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this version matches the passed one.
|
||||||
|
*/
|
||||||
|
default boolean isSame(int otherMajor, int otherMinor, int otherMicro) {
|
||||||
|
return isSame( otherMajor, otherMinor ) && getDatabaseMicroVersion() == otherMicro;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link #isSame} or {@link #isAfter}
|
||||||
|
*/
|
||||||
|
default boolean isSince(DatabaseVersion other) {
|
||||||
|
return isSince( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link #isSame} or {@link #isAfter}
|
||||||
|
*/
|
||||||
|
default boolean isSince(Integer otherMajor, Integer otherMinor) {
|
||||||
|
return isSince(
|
||||||
|
(int) otherMajor,
|
||||||
|
otherMinor == null ? NO_VERSION : otherMinor
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link #isSame} or {@link #isAfter}
|
||||||
|
*/
|
||||||
|
default boolean isSince(int otherMajor) {
|
||||||
|
final int major = getDatabaseMajorVersion();
|
||||||
|
|
||||||
|
return major >= otherMajor;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link #isSame} or {@link #isAfter}
|
||||||
|
*/
|
||||||
|
default boolean isSince(int otherMajor, int otherMinor) {
|
||||||
|
final int major = getDatabaseMajorVersion();
|
||||||
|
final int minor = getDatabaseMinorVersion();
|
||||||
|
|
||||||
|
return major > otherMajor
|
||||||
|
|| ( major == otherMajor && minor >= otherMinor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link #isSame} or {@link #isAfter}
|
||||||
|
*/
|
||||||
|
default boolean isSince(int otherMajor, int otherMinor, int otherMicro) {
|
||||||
|
final int major = getDatabaseMajorVersion();
|
||||||
|
final int minor = getDatabaseMinorVersion();
|
||||||
|
final int micro = getDatabaseMicroVersion();
|
||||||
|
|
||||||
|
return major > otherMajor
|
||||||
|
|| ( major == otherMajor && minor > otherMinor )
|
||||||
|
|| ( major == otherMajor && minor == otherMinor && micro >= otherMicro );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version comes after the passed one
|
||||||
|
*/
|
||||||
default boolean isAfter(DatabaseVersion other) {
|
default boolean isAfter(DatabaseVersion other) {
|
||||||
return isAfter( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
|
return isAfter( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version after the passed one
|
||||||
|
*/
|
||||||
|
default boolean isAfter(Integer major, Integer minor) {
|
||||||
|
return isAfter( (int) major, minor == null ? NO_VERSION : minor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version after the passed one
|
||||||
|
*/
|
||||||
|
default boolean isAfter(int major) {
|
||||||
|
return getDatabaseMajorVersion() > major;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version after the passed one
|
||||||
|
*/
|
||||||
default boolean isAfter(int major, int minor) {
|
default boolean isAfter(int major, int minor) {
|
||||||
return getDatabaseMajorVersion() > major
|
return getDatabaseMajorVersion() > major
|
||||||
|| ( getDatabaseMajorVersion() == major && getDatabaseMinorVersion() > minor );
|
|| ( getDatabaseMajorVersion() == major && getDatabaseMinorVersion() > minor );
|
||||||
}
|
}
|
||||||
|
|
||||||
default boolean isAfter(Integer major, Integer minor) {
|
/**
|
||||||
return isAfter( (int) major, minor == null ? NO_VERSION : minor );
|
* Determine whether this version after the passed one
|
||||||
|
*/
|
||||||
|
default boolean isAfter(int otherMajor, int otherMinor, int otherMicro) {
|
||||||
|
final int major = getDatabaseMajorVersion();
|
||||||
|
final int minor = getDatabaseMinorVersion();
|
||||||
|
final int micro = getDatabaseMicroVersion();
|
||||||
|
|
||||||
|
return major > otherMajor
|
||||||
|
|| ( major == otherMajor && minor > otherMinor )
|
||||||
|
|| ( major == otherMajor && minor == otherMinor && otherMicro > micro );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version comes before the passed one
|
||||||
|
*/
|
||||||
|
default boolean isBefore(DatabaseVersion other) {
|
||||||
|
return isBefore( other.getDatabaseMajorVersion(), other.getDatabaseMinorVersion() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version before the passed one
|
||||||
|
*/
|
||||||
|
default boolean isBefore(int major, int minor) {
|
||||||
|
return ! isSince( major, minor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version before the passed one
|
||||||
|
*/
|
||||||
|
default boolean isBefore(int major) {
|
||||||
|
return ! isSince( major );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version before the passed one
|
||||||
|
*/
|
||||||
|
default boolean isBefore(Integer major, Integer minor) {
|
||||||
|
return isBefore( (int) major, minor == null ? NO_VERSION : minor );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether this version before the passed one
|
||||||
|
*/
|
||||||
|
default boolean isBefore(int otherMajor, int otherMinor, int otherMicro) {
|
||||||
|
return ! isSince( otherMajor, otherMinor, otherMicro );
|
||||||
|
}
|
||||||
|
|
||||||
|
default int getMajor() {
|
||||||
|
return getDatabaseMajorVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
default int getMinor() {
|
||||||
|
return getDatabaseMinorVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
default int getMicro() {
|
||||||
|
return getDatabaseMicroVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,24 +91,24 @@ public class DerbyDialect extends Dialect {
|
|||||||
// * can't select a parameter unless wrapped
|
// * can't select a parameter unless wrapped
|
||||||
// in a cast or function call
|
// in a cast or function call
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
public DerbyDialect(DialectResolutionInfo info) {
|
public DerbyDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DerbyDialect() {
|
public DerbyDialect() {
|
||||||
this(1000);
|
this( DatabaseVersion.make( 10, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public DerbyDialect(int version) {
|
public DerbyDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
if ( getVersion() < 1070) {
|
if ( getVersion().isBefore( 10, 7 ) ) {
|
||||||
registerColumnType( Types.BOOLEAN, "smallint" ); //no boolean before 10.7
|
registerColumnType( Types.BOOLEAN, "smallint" ); //no boolean before 10.7
|
||||||
}
|
}
|
||||||
registerColumnType( Types.TINYINT, "smallint" ); //no tinyint
|
registerColumnType( Types.TINYINT, "smallint" ); //no tinyint
|
||||||
@ -135,21 +135,20 @@ public DerbyDialect(int version) {
|
|||||||
|
|
||||||
registerDerbyKeywords();
|
registerDerbyKeywords();
|
||||||
|
|
||||||
limitHandler = getVersion() < 1050
|
limitHandler = getVersion().isBefore( 10, 5 )
|
||||||
? AbstractLimitHandler.NO_LIMIT
|
? AbstractLimitHandler.NO_LIMIT
|
||||||
: new DerbyLimitHandler( getVersion() >= 1060 );
|
: new DerbyLimitHandler( getVersion().isSince( 10, 6 ) );
|
||||||
|
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeName(int code, Size size) throws HibernateException {
|
public String getTypeName(int code, Size size) throws HibernateException {
|
||||||
switch ( code ) {
|
if ( code == Types.CHAR ) {
|
||||||
case Types.CHAR:
|
// This is the maximum size for the CHAR datatype on Derby
|
||||||
// This is the maximum size for the CHAR datatype on Derby
|
if ( size.getLength() > 254 ) {
|
||||||
if ( size.getLength() > 254 ) {
|
return "char(254)";
|
||||||
return "char(254)";
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return super.getTypeName( code, size );
|
return super.getTypeName( code, size );
|
||||||
}
|
}
|
||||||
@ -162,13 +161,13 @@ public int getDefaultDecimalPrecision() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getPreferredSqlTypeCodeForBoolean() {
|
public int getPreferredSqlTypeCodeForBoolean() {
|
||||||
return getVersion() < 1070
|
return getVersion().isBefore( 10, 7 )
|
||||||
? Types.SMALLINT
|
? Types.SMALLINT
|
||||||
: Types.BOOLEAN;
|
: Types.BOOLEAN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,7 +372,7 @@ public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
||||||
if ( getVersion() < 1070 ) {
|
if ( getVersion().isBefore( 10, 7 ) ) {
|
||||||
appender.appendSql( bool ? '1' : '0' );
|
appender.appendSql( bool ? '1' : '0' );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -383,21 +382,21 @@ public void appendBooleanValueString(SqlAppender appender, boolean bool) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
return getVersion() < 1060
|
return getVersion().isBefore( 10, 6 )
|
||||||
? super.getSequenceSupport()
|
? super.getSequenceSupport()
|
||||||
: DerbySequenceSupport.INSTANCE;
|
: DerbySequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return getVersion() < 1060
|
return getVersion().isBefore( 10, 6 )
|
||||||
? null
|
? null
|
||||||
: "select sys.sysschemas.schemaname as sequence_schema,sys.syssequences.* from sys.syssequences left join sys.sysschemas on sys.syssequences.schemaid=sys.sysschemas.schemaid";
|
: "select sys.sysschemas.schemaname as sequence_schema,sys.syssequences.* from sys.syssequences left join sys.sysschemas on sys.syssequences.schemaid=sys.sysschemas.schemaid";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
public SequenceInformationExtractor getSequenceInformationExtractor() {
|
||||||
return getVersion() < 1060
|
return getVersion().isBefore( 10, 6 )
|
||||||
? SequenceInformationExtractorNoOpImpl.INSTANCE
|
? SequenceInformationExtractorNoOpImpl.INSTANCE
|
||||||
: SequenceInformationExtractorDerbyDatabaseImpl.INSTANCE;
|
: SequenceInformationExtractorDerbyDatabaseImpl.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -520,7 +519,7 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeDescriptorRegistry();
|
.getJdbcTypeDescriptorRegistry();
|
||||||
if ( getVersion() < 1070 ) {
|
if ( getVersion().isBefore( 10, 7 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.BOOLEAN, SmallIntJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptor( Types.NUMERIC, DecimalJdbcType.INSTANCE );
|
||||||
@ -855,6 +854,6 @@ public boolean supportsPartitionBy() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsWindowFunctions() {
|
public boolean supportsWindowFunctions() {
|
||||||
// It seems at least the row_number function is supported as of 10.4
|
// It seems at least the row_number function is supported as of 10.4
|
||||||
return getVersion() >= 1040;
|
return getVersion().isSince( 10, 4 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,12 +259,12 @@ protected boolean needsMaxRows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsParameterOffsetFetchExpression() {
|
private boolean supportsParameterOffsetFetchExpression() {
|
||||||
return getDialect().getVersion() >= 1060;
|
return getDialect().getVersion().isSince( 10, 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsOffsetFetchClause() {
|
private boolean supportsOffsetFetchClause() {
|
||||||
// Before version 10.5 Derby didn't support OFFSET and FETCH
|
// Before version 10.5 Derby didn't support OFFSET and FETCH
|
||||||
return getDialect().getVersion() >= 1050;
|
return getDialect().getVersion().isSince( 10, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,6 @@
|
|||||||
public class DerbyTenFiveDialect extends DerbyDialect {
|
public class DerbyTenFiveDialect extends DerbyDialect {
|
||||||
|
|
||||||
public DerbyTenFiveDialect() {
|
public DerbyTenFiveDialect() {
|
||||||
super(1050);
|
super( DatabaseVersion.make( 10, 5 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@
|
|||||||
public class DerbyTenSevenDialect extends DerbyDialect {
|
public class DerbyTenSevenDialect extends DerbyDialect {
|
||||||
|
|
||||||
public DerbyTenSevenDialect() {
|
public DerbyTenSevenDialect() {
|
||||||
super(1070);
|
super( DatabaseVersion.make( 10, 7 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
public class DerbyTenSixDialect extends DerbyDialect {
|
public class DerbyTenSixDialect extends DerbyDialect {
|
||||||
|
|
||||||
public DerbyTenSixDialect() {
|
public DerbyTenSixDialect() {
|
||||||
super(1060);
|
super( DatabaseVersion.make( 10, 6 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,42 +6,97 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.sql.Blob;
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.Clob;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.NClob;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.time.OffsetDateTime;
|
||||||
|
import java.time.temporal.TemporalAccessor;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
import org.hibernate.NotYetImplementedFor6Exception;
|
||||||
import org.hibernate.boot.TempTableDdlTransactionHandling;
|
|
||||||
import org.hibernate.dialect.sequence.NoSequenceSupport;
|
|
||||||
import org.hibernate.dialect.temptable.TemporaryTableExporter;
|
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
|
||||||
import org.hibernate.internal.util.MathHelper;
|
|
||||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
|
||||||
import org.hibernate.query.FetchClauseType;
|
|
||||||
import org.hibernate.query.IntervalType;
|
|
||||||
import org.hibernate.query.NullOrdering;
|
|
||||||
import org.hibernate.ScrollMode;
|
import org.hibernate.ScrollMode;
|
||||||
|
import org.hibernate.boot.TempTableDdlTransactionHandling;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
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.dialect.function.*;
|
import org.hibernate.dialect.function.CastFunction;
|
||||||
|
import org.hibernate.dialect.function.CastStrEmulation;
|
||||||
|
import org.hibernate.dialect.function.CoalesceIfnullEmulation;
|
||||||
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
|
import org.hibernate.dialect.function.CurrentFunction;
|
||||||
|
import org.hibernate.dialect.function.ExtractFunction;
|
||||||
|
import org.hibernate.dialect.function.InsertSubstringOverlayEmulation;
|
||||||
|
import org.hibernate.dialect.function.LocatePositionEmulation;
|
||||||
|
import org.hibernate.dialect.function.LpadRpadPadEmulation;
|
||||||
|
import org.hibernate.dialect.function.SqlFunction;
|
||||||
|
import org.hibernate.dialect.function.TimestampaddFunction;
|
||||||
|
import org.hibernate.dialect.function.TimestampdiffFunction;
|
||||||
|
import org.hibernate.dialect.function.TrimFunction;
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
|
import org.hibernate.dialect.identity.IdentityColumnSupportImpl;
|
||||||
import org.hibernate.dialect.lock.*;
|
import org.hibernate.dialect.lock.LockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.OptimisticForceIncrementLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.OptimisticLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticForceIncrementLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticReadSelectLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.PessimisticWriteSelectLockingStrategy;
|
||||||
|
import org.hibernate.dialect.lock.SelectLockingStrategy;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
|
import org.hibernate.dialect.sequence.NoSequenceSupport;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
|
import org.hibernate.dialect.temptable.StandardTemporaryTableExporter;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTable;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTableExporter;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
||||||
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
|
import org.hibernate.dialect.unique.DefaultUniqueDelegate;
|
||||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||||
import org.hibernate.engine.jdbc.LobCreator;
|
import org.hibernate.engine.jdbc.LobCreator;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver;
|
import org.hibernate.engine.jdbc.env.internal.DefaultSchemaNameResolver;
|
||||||
import org.hibernate.engine.jdbc.env.spi.*;
|
import org.hibernate.engine.jdbc.env.spi.AnsiSqlKeywords;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.SchemaNameResolver;
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.exception.spi.ConversionContext;
|
import org.hibernate.exception.spi.ConversionContext;
|
||||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||||
import org.hibernate.exception.spi.SQLExceptionConverter;
|
import org.hibernate.exception.spi.SQLExceptionConverter;
|
||||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
||||||
|
import org.hibernate.internal.util.MathHelper;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.internal.util.collections.ArrayHelper;
|
import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.internal.util.io.StreamCopier;
|
import org.hibernate.internal.util.io.StreamCopier;
|
||||||
@ -51,29 +106,30 @@
|
|||||||
import org.hibernate.mapping.Index;
|
import org.hibernate.mapping.Index;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
|
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||||
import org.hibernate.metamodel.mapping.SqlExpressable;
|
import org.hibernate.metamodel.mapping.SqlExpressable;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.procedure.internal.StandardCallableStatementSupport;
|
import org.hibernate.procedure.internal.StandardCallableStatementSupport;
|
||||||
import org.hibernate.procedure.spi.CallableStatementSupport;
|
import org.hibernate.procedure.spi.CallableStatementSupport;
|
||||||
import org.hibernate.query.CastType;
|
import org.hibernate.query.CastType;
|
||||||
|
import org.hibernate.query.FetchClauseType;
|
||||||
|
import org.hibernate.query.IntervalType;
|
||||||
|
import org.hibernate.query.NullOrdering;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.TrimSpec;
|
import org.hibernate.query.TrimSpec;
|
||||||
import org.hibernate.query.hql.HqlTranslator;
|
import org.hibernate.query.hql.HqlTranslator;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.spi.QueryOptions;
|
import org.hibernate.query.spi.QueryOptions;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTable;
|
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableMutationStrategy;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
|
||||||
import org.hibernate.dialect.temptable.StandardTemporaryTableExporter;
|
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||||
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
import org.hibernate.query.sqm.sql.SqmTranslatorFactory;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
import org.hibernate.sql.*;
|
import org.hibernate.sql.ForUpdateFragment;
|
||||||
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
||||||
import org.hibernate.sql.ast.spi.SqlAppender;
|
import org.hibernate.sql.ast.spi.SqlAppender;
|
||||||
@ -81,7 +137,12 @@
|
|||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
||||||
import org.hibernate.tool.schema.internal.*;
|
import org.hibernate.tool.schema.internal.StandardAuxiliaryDatabaseObjectExporter;
|
||||||
|
import org.hibernate.tool.schema.internal.StandardForeignKeyExporter;
|
||||||
|
import org.hibernate.tool.schema.internal.StandardIndexExporter;
|
||||||
|
import org.hibernate.tool.schema.internal.StandardSequenceExporter;
|
||||||
|
import org.hibernate.tool.schema.internal.StandardTableExporter;
|
||||||
|
import org.hibernate.tool.schema.internal.StandardUniqueKeyExporter;
|
||||||
import org.hibernate.tool.schema.spi.Exporter;
|
import org.hibernate.tool.schema.spi.Exporter;
|
||||||
import org.hibernate.type.BasicType;
|
import org.hibernate.type.BasicType;
|
||||||
import org.hibernate.type.BasicTypeRegistry;
|
import org.hibernate.type.BasicTypeRegistry;
|
||||||
@ -99,21 +160,14 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.sql.*;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.time.LocalTime;
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.time.temporal.TemporalAccessor;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.*;
|
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_END;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_DATE;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_TIME;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.JDBC_ESCAPE_START_TIMESTAMP;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsDate;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTime;
|
||||||
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithMicros;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a dialect of SQL implemented by a particular RDBMS. Subclasses
|
* Represents a dialect of SQL implemented by a particular RDBMS. Subclasses
|
||||||
@ -263,6 +317,8 @@ protected void registerKeywords(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract DatabaseVersion getVersion();
|
||||||
|
|
||||||
public JdbcType resolveSqlTypeDescriptor(
|
public JdbcType resolveSqlTypeDescriptor(
|
||||||
String columnTypeName,
|
String columnTypeName,
|
||||||
int jdbcTypeCode,
|
int jdbcTypeCode,
|
||||||
@ -381,8 +437,6 @@ else if ( isNumericType(sqlType) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int getVersion();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the given registry with any dialect-specific functions.
|
* Initialize the given registry with any dialect-specific functions.
|
||||||
*
|
*
|
||||||
@ -1456,7 +1510,6 @@ public SequenceSupport getSequenceSupport() {
|
|||||||
* Get the select command used retrieve the names of all sequences.
|
* Get the select command used retrieve the names of all sequences.
|
||||||
*
|
*
|
||||||
* @return The select command; or null if sequences are not supported.
|
* @return The select command; or null if sequences are not supported.
|
||||||
* @see org.hibernate.tool.hbm2ddl.SchemaUpdate
|
|
||||||
*/
|
*/
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return null;
|
return null;
|
||||||
|
@ -8,13 +8,8 @@
|
|||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
|
||||||
import org.hibernate.query.FetchClauseType;
|
|
||||||
import org.hibernate.query.IntervalType;
|
|
||||||
import org.hibernate.query.NullOrdering;
|
|
||||||
import org.hibernate.PessimisticLockException;
|
import org.hibernate.PessimisticLockException;
|
||||||
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
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;
|
||||||
@ -25,6 +20,8 @@
|
|||||||
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
||||||
import org.hibernate.dialect.sequence.H2SequenceSupport;
|
import org.hibernate.dialect.sequence.H2SequenceSupport;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTable;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.exception.ConstraintViolationException;
|
import org.hibernate.exception.ConstraintViolationException;
|
||||||
@ -32,17 +29,19 @@
|
|||||||
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
import org.hibernate.exception.spi.SQLExceptionConversionDelegate;
|
||||||
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor;
|
||||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
||||||
|
import org.hibernate.internal.CoreLogging;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
|
import org.hibernate.query.FetchClauseType;
|
||||||
|
import org.hibernate.query.IntervalType;
|
||||||
|
import org.hibernate.query.NullOrdering;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTable;
|
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||||
import org.hibernate.service.ServiceRegistry;
|
import org.hibernate.service.ServiceRegistry;
|
||||||
@ -61,7 +60,7 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.query.TemporalUnit.SECOND;
|
import static org.hibernate.query.TemporalUnit.SECOND;
|
||||||
|
|
||||||
@ -71,74 +70,75 @@
|
|||||||
* @author Thomas Mueller
|
* @author Thomas Mueller
|
||||||
*/
|
*/
|
||||||
public class H2Dialect extends Dialect {
|
public class H2Dialect extends Dialect {
|
||||||
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( H2Dialect.class );
|
||||||
CoreMessageLogger.class,
|
|
||||||
H2Dialect.class.getName()
|
|
||||||
);
|
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
|
|
||||||
private final boolean cascadeConstraints;
|
private final boolean cascadeConstraints;
|
||||||
private final boolean useLocalTime;
|
private final boolean useLocalTime;
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private final boolean supportsTuplesInSubqueries;
|
private final boolean supportsTuplesInSubqueries;
|
||||||
private final SequenceInformationExtractor sequenceInformationExtractor;
|
private final SequenceInformationExtractor sequenceInformationExtractor;
|
||||||
private final String querySequenceString;
|
private final String querySequenceString;
|
||||||
|
|
||||||
public H2Dialect(DialectResolutionInfo info) {
|
public H2Dialect(DialectResolutionInfo info) {
|
||||||
this(
|
this( parseVersion( info ) );
|
||||||
info.getDatabaseMajorVersion() * 100000
|
|
||||||
+ info.getDatabaseMinorVersion() * 1000,
|
|
||||||
parseBuildId( info )
|
|
||||||
);
|
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static DatabaseVersion parseVersion(DialectResolutionInfo info) {
|
||||||
|
return DatabaseVersion.make( info.getMajor(), info.getMinor(), parseBuildId( info ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int parseBuildId(DialectResolutionInfo info) {
|
||||||
|
final String databaseVersion = info.getDatabaseVersion();
|
||||||
|
if ( databaseVersion == null ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] bits = databaseVersion.split("[. ]");
|
||||||
|
return bits.length > 2 ? Integer.parseInt( bits[2] ) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public H2Dialect() {
|
public H2Dialect() {
|
||||||
this(0, 0);
|
this( SimpleDatabaseVersion.ZERO_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
public H2Dialect(int version, int buildId) {
|
public H2Dialect(DatabaseVersion version) {
|
||||||
this(version + buildId);
|
|
||||||
}
|
|
||||||
|
|
||||||
public H2Dialect(int version) {
|
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
// https://github.com/h2database/h2database/commit/b2cdf84e0b84eb8a482fa7dccdccc1ab95241440
|
// https://github.com/h2database/h2database/commit/b2cdf84e0b84eb8a482fa7dccdccc1ab95241440
|
||||||
limitHandler = version >= 104195
|
limitHandler = version.isSince( 1, 4, 195 )
|
||||||
? OffsetFetchLimitHandler.INSTANCE
|
? OffsetFetchLimitHandler.INSTANCE
|
||||||
: LimitOffsetLimitHandler.INSTANCE;
|
: LimitOffsetLimitHandler.INSTANCE;
|
||||||
|
|
||||||
if ( version < 102139 ) {
|
if ( version.isBefore( 1, 2, 139 ) ) {
|
||||||
final int majorVersion = version / 100000;
|
LOG.unsupportedMultiTableBulkHqlJpaql( version.getMajor(), version.getMinor(), version.getMicro() );
|
||||||
final int minorVersion = version % 100000 / 1000;
|
|
||||||
final int buildId = version % 1000;
|
|
||||||
LOG.unsupportedMultiTableBulkHqlJpaql( majorVersion, minorVersion, buildId );
|
|
||||||
}
|
}
|
||||||
supportsTuplesInSubqueries = version >= 104198;
|
|
||||||
|
supportsTuplesInSubqueries = version.isSince( 1, 4, 198 );
|
||||||
// Prior to 1.4.200 the 'cascade' in 'drop table' was implicit
|
// Prior to 1.4.200 the 'cascade' in 'drop table' was implicit
|
||||||
cascadeConstraints = version >= 104200;
|
cascadeConstraints = version.isSince( 1, 4, 200 );
|
||||||
// 1.4.200 introduced changes in current_time and current_timestamp
|
// 1.4.200 introduced changes in current_time and current_timestamp
|
||||||
useLocalTime = version >= 104199;
|
useLocalTime = version.isSince( 1, 4, 200 );
|
||||||
|
|
||||||
getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
getDefaultProperties().setProperty( AvailableSettings.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
// http://code.google.com/p/h2database/issues/detail?id=235
|
// http://code.google.com/p/h2database/issues/detail?id=235
|
||||||
getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" );
|
getDefaultProperties().setProperty( AvailableSettings.NON_CONTEXTUAL_LOB_CREATION, "true" );
|
||||||
|
|
||||||
registerColumnType( SqlTypes.ARRAY, "array" );
|
registerColumnType( SqlTypes.ARRAY, "array" );
|
||||||
if ( version >= 104032 ) {
|
if ( version.isSince( 1, 4, 32 ) ) {
|
||||||
this.sequenceInformationExtractor = version >= 104201
|
this.sequenceInformationExtractor = version.isSince( 1, 4, 201 )
|
||||||
? SequenceInformationExtractorLegacyImpl.INSTANCE
|
? SequenceInformationExtractorLegacyImpl.INSTANCE
|
||||||
: SequenceInformationExtractorH2DatabaseImpl.INSTANCE;
|
: SequenceInformationExtractorH2DatabaseImpl.INSTANCE;
|
||||||
this.querySequenceString = "select * from INFORMATION_SCHEMA.SEQUENCES";
|
this.querySequenceString = "select * from INFORMATION_SCHEMA.SEQUENCES";
|
||||||
registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
|
registerColumnType( Types.DECIMAL, "numeric($p,$s)" );
|
||||||
if ( version >= 104197 ) {
|
if ( version.isSince( 1, 4, 197 ) ) {
|
||||||
registerColumnType( SqlTypes.UUID, "uuid" );
|
registerColumnType( SqlTypes.UUID, "uuid" );
|
||||||
registerColumnType( SqlTypes.GEOMETRY, "geometry" );
|
registerColumnType( SqlTypes.GEOMETRY, "geometry" );
|
||||||
if ( version >= 104198 ) {
|
if ( version.isSince( 1, 4, 198 ) ) {
|
||||||
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($p,$s)" );
|
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($p,$s)" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ public H2Dialect(int version) {
|
|||||||
else {
|
else {
|
||||||
this.sequenceInformationExtractor = SequenceInformationExtractorNoOpImpl.INSTANCE;
|
this.sequenceInformationExtractor = SequenceInformationExtractorNoOpImpl.INSTANCE;
|
||||||
this.querySequenceString = null;
|
this.querySequenceString = null;
|
||||||
if ( version < 200 ) {
|
if ( version.isBefore( 2 ) ) {
|
||||||
// prior to version 2.0, H2 reported NUMERIC columns as DECIMAL,
|
// prior to version 2.0, H2 reported NUMERIC columns as DECIMAL,
|
||||||
// which caused problems for schema update tool
|
// which caused problems for schema update tool
|
||||||
registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
|
registerColumnType( Types.NUMERIC, "decimal($p,$s)" );
|
||||||
@ -161,31 +161,21 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeDescriptorRegistry();
|
.getJdbcTypeDescriptorRegistry();
|
||||||
|
|
||||||
if ( version >= 104197 ) {
|
if ( version.isSince( 1, 4, 197 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
||||||
if ( version >= 104198 ) {
|
if ( version.isSince( 1, 4, 198 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( DurationIntervalSecondJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( DurationIntervalSecondJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int parseBuildId(DialectResolutionInfo info) {
|
public boolean hasOddDstBehavior() {
|
||||||
final String databaseVersion = info.getDatabaseVersion();
|
|
||||||
if ( databaseVersion == null ) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String[] bits = databaseVersion.split("[. ]");
|
|
||||||
return bits.length > 2 ? Integer.parseInt( bits[2] ) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasDstBug() {
|
|
||||||
// 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() == 104200;
|
return getVersion().isSame( 1, 4, 200 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +230,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.median( queryEngine );
|
CommonFunctionFactory.median( queryEngine );
|
||||||
CommonFunctionFactory.stddevPopSamp( queryEngine );
|
CommonFunctionFactory.stddevPopSamp( queryEngine );
|
||||||
CommonFunctionFactory.varPopSamp( queryEngine );
|
CommonFunctionFactory.varPopSamp( queryEngine );
|
||||||
if ( version == 104200 ) {
|
if ( version.isSame( 1, 4, 200 ) ) {
|
||||||
// See https://github.com/h2database/h2database/issues/2518
|
// See https://github.com/h2database/h2database/issues/2518
|
||||||
CommonFunctionFactory.format_toChar( queryEngine );
|
CommonFunctionFactory.format_toChar( queryEngine );
|
||||||
}
|
}
|
||||||
@ -509,7 +499,7 @@ public boolean supportsOffsetInSubquery() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsFetchClause(FetchClauseType type) {
|
public boolean supportsFetchClause(FetchClauseType type) {
|
||||||
return getVersion() >= 104198;
|
return getVersion().isSince( 1, 4, 198 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -524,7 +514,7 @@ public String getQueryHintString(String query, String hints) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void appendDatetimeFormat(SqlAppender appender, String format) {
|
public void appendDatetimeFormat(SqlAppender appender, String format) {
|
||||||
if ( version == 104200 ) {
|
if ( version.isSame( 1, 4, 200 ) ) {
|
||||||
// See https://github.com/h2database/h2database/issues/2518
|
// See https://github.com/h2database/h2database/issues/2518
|
||||||
appender.appendSql( OracleDialect.datetimeFormat( format, true, true ).result() );
|
appender.appendSql( OracleDialect.datetimeFormat( format, true, true ).result() );
|
||||||
}
|
}
|
||||||
|
@ -119,12 +119,12 @@ protected String getFromDual() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsOffsetFetchClause() {
|
private boolean supportsOffsetFetchClause() {
|
||||||
return getDialect().getVersion() >= 104195;
|
return getDialect().getVersion().isSince( 1, 4, 195 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsOffsetFetchClausePercentWithTies() {
|
private boolean supportsOffsetFetchClausePercentWithTies() {
|
||||||
// Introduction of TIES clause https://github.com/h2database/h2database/commit/876e9fbe7baf11d01675bfe871aac2cf1b6104ce
|
// Introduction of TIES clause https://github.com/h2database/h2database/commit/876e9fbe7baf11d01675bfe871aac2cf1b6104ce
|
||||||
// Introduction of PERCENT support https://github.com/h2database/h2database/commit/f45913302e5f6ad149155a73763c0c59d8205849
|
// Introduction of PERCENT support https://github.com/h2database/h2database/commit/f45913302e5f6ad149155a73763c0c59d8205849
|
||||||
return getDialect().getVersion() >= 104198;
|
return getDialect().getVersion().isSince( 1, 4, 198 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
public class HANACloudColumnStoreDialect extends HANAColumnStoreDialect {
|
public class HANACloudColumnStoreDialect extends HANAColumnStoreDialect {
|
||||||
|
|
||||||
public HANACloudColumnStoreDialect() {
|
public HANACloudColumnStoreDialect() {
|
||||||
super( 400 );
|
super( DatabaseVersion.make( 4 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -35,21 +35,18 @@
|
|||||||
* @author <a href="mailto:jonathan.bregler@sap.com">Jonathan Bregler</a>
|
* @author <a href="mailto:jonathan.bregler@sap.com">Jonathan Bregler</a>
|
||||||
*/
|
*/
|
||||||
public class HANAColumnStoreDialect extends AbstractHANADialect {
|
public class HANAColumnStoreDialect extends AbstractHANADialect {
|
||||||
private final int version;
|
|
||||||
|
|
||||||
public HANAColumnStoreDialect(DialectResolutionInfo info) {
|
public HANAColumnStoreDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HANAColumnStoreDialect() {
|
public HANAColumnStoreDialect() {
|
||||||
this( 300 );
|
this( DatabaseVersion.make( 3, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HANAColumnStoreDialect(int version) {
|
public HANAColumnStoreDialect(DatabaseVersion version) {
|
||||||
super();
|
super( version );
|
||||||
this.version = version;
|
if ( version.isSince( 4 ) ) {
|
||||||
if ( this.version >= 400 ) {
|
|
||||||
registerColumnType( Types.CHAR, "nvarchar(1)" );
|
registerColumnType( Types.CHAR, "nvarchar(1)" );
|
||||||
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
|
registerColumnType( Types.VARCHAR, 5000, "nvarchar($l)" );
|
||||||
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
|
registerColumnType( Types.LONGVARCHAR, 5000, "nvarchar($l)" );
|
||||||
@ -73,7 +70,7 @@ public HANAColumnStoreDialect(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion(){
|
public DatabaseVersion getVersion(){
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +174,7 @@ public String getTemporaryTableTruncateCommand() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportsAsciiStringTypes() {
|
protected boolean supportsAsciiStringTypes() {
|
||||||
if ( version >= 400 ) {
|
if ( version.isSince( 4 ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -185,7 +182,7 @@ protected boolean supportsAsciiStringTypes() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Boolean useUnicodeStringTypesDefault() {
|
protected Boolean useUnicodeStringTypesDefault() {
|
||||||
if ( version >= 400 ) {
|
if ( version.isSince( 4 ) ) {
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
@ -193,7 +190,7 @@ protected Boolean useUnicodeStringTypesDefault() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isUseUnicodeStringTypes() {
|
public boolean isUseUnicodeStringTypes() {
|
||||||
if ( version >= 400 ) {
|
if ( version.isSince( 4 ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.isUseUnicodeStringTypes();
|
return super.isUseUnicodeStringTypes();
|
||||||
|
@ -33,14 +33,18 @@
|
|||||||
public class HANARowStoreDialect extends AbstractHANADialect {
|
public class HANARowStoreDialect extends AbstractHANADialect {
|
||||||
|
|
||||||
public HANARowStoreDialect() {
|
public HANARowStoreDialect() {
|
||||||
super();
|
super( DatabaseVersion.make( 3, 0 ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public HANARowStoreDialect(DialectResolutionInfo info) {
|
public HANARowStoreDialect(DialectResolutionInfo info) {
|
||||||
super();
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HANARowStoreDialect(DatabaseVersion version) {
|
||||||
|
super( version );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCreateTableString() {
|
public String getCreateTableString() {
|
||||||
return "create row table";
|
return "create row table";
|
||||||
@ -96,11 +100,6 @@ public String getTemporaryTableTruncateCommand() {
|
|||||||
return "truncate table";
|
return "truncate table";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getVersion() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportsAsciiStringTypes() {
|
protected boolean supportsAsciiStringTypes() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -9,12 +9,8 @@
|
|||||||
import java.sql.DatabaseMetaData;
|
import java.sql.DatabaseMetaData;
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.hibernate.JDBCException;
|
import org.hibernate.JDBCException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.query.IntervalType;
|
|
||||||
import org.hibernate.query.NullOrdering;
|
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
@ -33,6 +29,8 @@
|
|||||||
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
import org.hibernate.dialect.pagination.OffsetFetchLimitHandler;
|
||||||
import org.hibernate.dialect.sequence.HSQLSequenceSupport;
|
import org.hibernate.dialect.sequence.HSQLSequenceSupport;
|
||||||
import org.hibernate.dialect.sequence.SequenceSupport;
|
import org.hibernate.dialect.sequence.SequenceSupport;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTable;
|
||||||
|
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
@ -46,16 +44,16 @@
|
|||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.Lockable;
|
import org.hibernate.persister.entity.Lockable;
|
||||||
import org.hibernate.query.CastType;
|
import org.hibernate.query.CastType;
|
||||||
|
import org.hibernate.query.IntervalType;
|
||||||
|
import org.hibernate.query.NullOrdering;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.BeforeUseAction;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableMutationStrategy;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTable;
|
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
|
||||||
import org.hibernate.dialect.temptable.TemporaryTableKind;
|
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||||
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
||||||
@ -70,6 +68,8 @@
|
|||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -88,21 +88,21 @@ public class HSQLDialect extends Dialect {
|
|||||||
/**
|
/**
|
||||||
* version is 180 for 1.8.0 or 200 for 2.0.0
|
* version is 180 for 1.8.0 or 200 for 2.0.0
|
||||||
*/
|
*/
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
public HSQLDialect(DialectResolutionInfo info) {
|
public HSQLDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10 );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSQLDialect() {
|
public HSQLDialect() {
|
||||||
this( 180 );
|
this( DatabaseVersion.make( 1, 8 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public HSQLDialect(int version) {
|
public HSQLDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
if ( version == 180 ) {
|
if ( version.isSame( 1, 8 ) ) {
|
||||||
version = reflectedVersion( version );
|
version = reflectedVersion( version );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ public HSQLDialect(int version) {
|
|||||||
//(See HHH-10364)
|
//(See HHH-10364)
|
||||||
registerColumnType( Types.NCLOB, "clob" );
|
registerColumnType( Types.NCLOB, "clob" );
|
||||||
|
|
||||||
if ( this.version < 200 ) {
|
if ( this.version.isBefore( 2 ) ) {
|
||||||
//Older versions of HSQL did not accept
|
//Older versions of HSQL did not accept
|
||||||
//precision for the 'numeric' type
|
//precision for the 'numeric' type
|
||||||
registerColumnType( Types.NUMERIC, "numeric" );
|
registerColumnType( Types.NUMERIC, "numeric" );
|
||||||
@ -128,21 +128,23 @@ public HSQLDialect(int version) {
|
|||||||
registerColumnType( Types.CLOB, "longvarchar" );
|
registerColumnType( Types.CLOB, "longvarchar" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( this.version >= 250 ) {
|
if ( this.version.isSince( 2, 5 ) ) {
|
||||||
registerKeyword( "period" );
|
registerKeyword( "period" );
|
||||||
}
|
}
|
||||||
|
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int reflectedVersion(int 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");
|
||||||
final String versionString = (String) props.getDeclaredField("THIS_VERSION").get( null );
|
final String versionString = (String) props.getDeclaredField("THIS_VERSION").get( null );
|
||||||
|
|
||||||
return Integer.parseInt( versionString.substring(0, 1) ) * 100
|
return new SimpleDatabaseVersion(
|
||||||
+ Integer.parseInt( versionString.substring(2, 3) ) * 10
|
Integer.parseInt( versionString.substring( 0, 1 ) ),
|
||||||
+ Integer.parseInt( versionString.substring(4, 5) );
|
Integer.parseInt( versionString.substring( 2, 3 ) ),
|
||||||
|
Integer.parseInt( versionString.substring( 4, 5 ) )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (Throwable e) {
|
catch (Throwable e) {
|
||||||
// might be a very old version, or not accessible in class path
|
// might be a very old version, or not accessible in class path
|
||||||
@ -151,7 +153,7 @@ private static int reflectedVersion(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,13 +208,13 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.addMonths( queryEngine );
|
CommonFunctionFactory.addMonths( queryEngine );
|
||||||
CommonFunctionFactory.monthsBetween( queryEngine );
|
CommonFunctionFactory.monthsBetween( queryEngine );
|
||||||
|
|
||||||
if ( version >= 200 ) {
|
if ( version.isSince( 2 ) ) {
|
||||||
//SYSDATE is similar to LOCALTIMESTAMP but it returns the timestamp when it is called
|
//SYSDATE is similar to LOCALTIMESTAMP but it returns the timestamp when it is called
|
||||||
CommonFunctionFactory.sysdate( queryEngine );
|
CommonFunctionFactory.sysdate( queryEngine );
|
||||||
}
|
}
|
||||||
|
|
||||||
// from v. 2.2.0 ROWNUM() is supported in all modes as the equivalent of Oracle ROWNUM
|
// from v. 2.2.0 ROWNUM() is supported in all modes as the equivalent of Oracle ROWNUM
|
||||||
if ( version > 219 ) {
|
if ( version.isSince( 2, 2 ) ) {
|
||||||
CommonFunctionFactory.rownum( queryEngine );
|
CommonFunctionFactory.rownum( queryEngine );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -355,7 +357,7 @@ public boolean supportsLockTimeouts() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getForUpdateString() {
|
public String getForUpdateString() {
|
||||||
if ( version >= 200 ) {
|
if ( version.isSince( 2 ) ) {
|
||||||
return " for update";
|
return " for update";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -365,8 +367,8 @@ public String getForUpdateString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LimitHandler getLimitHandler() {
|
public LimitHandler getLimitHandler() {
|
||||||
return version < 200 ? LegacyHSQLLimitHandler.INSTANCE
|
return version.isBefore( 2 ) ? LegacyHSQLLimitHandler.INSTANCE
|
||||||
: version < 250 ? LimitOffsetLimitHandler.INSTANCE
|
: version.isBefore( 2, 5 ) ? LimitOffsetLimitHandler.INSTANCE
|
||||||
: OffsetFetchLimitHandler.INSTANCE;
|
: OffsetFetchLimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -385,7 +387,7 @@ public boolean supportsIfExistsBeforeTableName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsColumnCheck() {
|
public boolean supportsColumnCheck() {
|
||||||
return version >= 200;
|
return version.isSince( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -406,7 +408,7 @@ public SequenceInformationExtractor getSequenceInformationExtractor() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
||||||
return version < 200 ? EXTRACTOR_18 : EXTRACTOR_20;
|
return version.isBefore( 2 ) ? EXTRACTOR_18 : EXTRACTOR_20;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ViolatedConstraintNameExtractor EXTRACTOR_18 =
|
private static final ViolatedConstraintNameExtractor EXTRACTOR_18 =
|
||||||
@ -516,7 +518,7 @@ public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(
|
|||||||
// the definition and data is private to the session and table declaration
|
// the definition and data is private to the session and table declaration
|
||||||
// can happen in the middle of a transaction
|
// can happen in the middle of a transaction
|
||||||
|
|
||||||
if ( version < 200 ) {
|
if ( version.isBefore( 2 ) ) {
|
||||||
return new GlobalTemporaryTableMutationStrategy(
|
return new GlobalTemporaryTableMutationStrategy(
|
||||||
TemporaryTable.createIdTable(
|
TemporaryTable.createIdTable(
|
||||||
rootEntityDescriptor,
|
rootEntityDescriptor,
|
||||||
@ -556,7 +558,7 @@ public SqmMultiTableInsertStrategy getFallbackSqmInsertStrategy(
|
|||||||
// the definition and data is private to the session and table declaration
|
// the definition and data is private to the session and table declaration
|
||||||
// can happen in the middle of a transaction
|
// can happen in the middle of a transaction
|
||||||
|
|
||||||
if ( version < 200 ) {
|
if ( version.isBefore( 2 ) ) {
|
||||||
return new GlobalTemporaryTableInsertStrategy(
|
return new GlobalTemporaryTableInsertStrategy(
|
||||||
TemporaryTable.createEntityTable(
|
TemporaryTable.createEntityTable(
|
||||||
rootEntityDescriptor,
|
rootEntityDescriptor,
|
||||||
@ -584,24 +586,24 @@ public SqmMultiTableInsertStrategy getFallbackSqmInsertStrategy(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TemporaryTableKind getSupportedTemporaryTableKind() {
|
public TemporaryTableKind getSupportedTemporaryTableKind() {
|
||||||
return version < 200 ? TemporaryTableKind.GLOBAL : TemporaryTableKind.LOCAL;
|
return version.isBefore( 2 ) ? TemporaryTableKind.GLOBAL : TemporaryTableKind.LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTemporaryTableCreateCommand() {
|
public String getTemporaryTableCreateCommand() {
|
||||||
return version < 200 ? super.getTemporaryTableCreateCommand() : "declare local temporary table";
|
return version.isBefore( 2 ) ? super.getTemporaryTableCreateCommand() : "declare local temporary table";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AfterUseAction getTemporaryTableAfterUseAction() {
|
public AfterUseAction getTemporaryTableAfterUseAction() {
|
||||||
// Version 1.8 GLOBAL TEMPORARY table definitions persist beyond the end
|
// Version 1.8 GLOBAL TEMPORARY table definitions persist beyond the end
|
||||||
// of the session (by default, data is cleared at commit).
|
// of the session (by default, data is cleared at commit).
|
||||||
return version < 200 ? AfterUseAction.CLEAN : AfterUseAction.DROP;
|
return version.isBefore( 2 ) ? AfterUseAction.CLEAN : AfterUseAction.DROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BeforeUseAction getTemporaryTableBeforeUseAction() {
|
public BeforeUseAction getTemporaryTableBeforeUseAction() {
|
||||||
return version < 200 ? BeforeUseAction.NONE : BeforeUseAction.CREATE;
|
return version.isBefore( 2 ) ? BeforeUseAction.NONE : BeforeUseAction.CREATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// current timestamp support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// current timestamp support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -649,7 +651,7 @@ public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode)
|
|||||||
case OPTIMISTIC_FORCE_INCREMENT:
|
case OPTIMISTIC_FORCE_INCREMENT:
|
||||||
return new OptimisticForceIncrementLockingStrategy(lockable, lockMode);
|
return new OptimisticForceIncrementLockingStrategy(lockable, lockMode);
|
||||||
}
|
}
|
||||||
if ( version < 200 ) {
|
if ( version.isBefore( 2 ) ) {
|
||||||
return new ReadUncommittedLockingStrategy( lockable, lockMode );
|
return new ReadUncommittedLockingStrategy( lockable, lockMode );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -674,19 +676,19 @@ public void lock(Object id, Object version, Object object, int timeout, SharedSe
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsCommentOn() {
|
public boolean supportsCommentOn() {
|
||||||
return version >= 200;
|
return version.isSince( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// Overridden informational metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesReadCommittedCauseWritersToBlockReaders() {
|
public boolean doesReadCommittedCauseWritersToBlockReaders() {
|
||||||
return version >= 200;
|
return version.isSince( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
|
public boolean doesRepeatableReadCauseReadersToBlockWriters() {
|
||||||
return version >= 200;
|
return version.isSince( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -707,7 +709,7 @@ public boolean supportsTupleCounts() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsTupleDistinctCounts() {
|
public boolean supportsTupleDistinctCounts() {
|
||||||
// from v. 2.2.9 is added support for COUNT(DISTINCT ...) with multiple arguments
|
// from v. 2.2.9 is added support for COUNT(DISTINCT ...) with multiple arguments
|
||||||
return version >= 229;
|
return version.isSince( 2, 2, 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -722,7 +724,7 @@ public boolean requiresFloatCastingOfIntegerDivision() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
return new HSQLIdentityColumnSupport( this.version);
|
return new HSQLIdentityColumnSupport( this.version );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -110,7 +110,7 @@ protected LockStrategy determineLockingStrategy(
|
|||||||
QuerySpec querySpec,
|
QuerySpec querySpec,
|
||||||
ForUpdateClause forUpdateClause,
|
ForUpdateClause forUpdateClause,
|
||||||
Boolean followOnLocking) {
|
Boolean followOnLocking) {
|
||||||
if ( getDialect().getVersion() < 200 ) {
|
if ( getDialect().getVersion().isBefore( 2 ) ) {
|
||||||
return LockStrategy.NONE;
|
return LockStrategy.NONE;
|
||||||
}
|
}
|
||||||
return super.determineLockingStrategy( querySpec, forUpdateClause, followOnLocking );
|
return super.determineLockingStrategy( querySpec, forUpdateClause, followOnLocking );
|
||||||
@ -118,7 +118,7 @@ protected LockStrategy determineLockingStrategy(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
||||||
if ( getDialect().getVersion() < 200 ) {
|
if ( getDialect().getVersion().isBefore( 2 ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.renderForUpdateClause( querySpec, forUpdateClause );
|
super.renderForUpdateClause( querySpec, forUpdateClause );
|
||||||
@ -215,6 +215,6 @@ protected String getFromDualForSelectOnly() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsOffsetFetchClause() {
|
private boolean supportsOffsetFetchClause() {
|
||||||
return getDialect().getVersion() >= 250;
|
return getDialect().getVersion().isSince( 2, 5 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
public class MariaDB102Dialect extends MariaDBDialect {
|
public class MariaDB102Dialect extends MariaDBDialect {
|
||||||
|
|
||||||
public MariaDB102Dialect() {
|
public MariaDB102Dialect() {
|
||||||
super(1020);
|
super( DatabaseVersion.make( 10, 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,10 +9,6 @@
|
|||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.dialect.function.StandardSQLFunction;
|
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorMariaDBDatabaseImpl;
|
|
||||||
import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor;
|
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An SQL dialect for MariaDB 10.3 and later, provides sequence support, lock-timeouts, etc.
|
* An SQL dialect for MariaDB 10.3 and later, provides sequence support, lock-timeouts, etc.
|
||||||
@ -25,7 +21,7 @@
|
|||||||
public class MariaDB103Dialect extends MariaDBDialect {
|
public class MariaDB103Dialect extends MariaDBDialect {
|
||||||
|
|
||||||
public MariaDB103Dialect() {
|
public MariaDB103Dialect() {
|
||||||
super(1030);
|
super( DatabaseVersion.make( 10, 3 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
public class MariaDB10Dialect extends MariaDBDialect {
|
public class MariaDB10Dialect extends MariaDBDialect {
|
||||||
|
|
||||||
public MariaDB10Dialect() {
|
public MariaDB10Dialect() {
|
||||||
super(1000);
|
super( DatabaseVersion.make( 10 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
public class MariaDB53Dialect extends MariaDBDialect {
|
public class MariaDB53Dialect extends MariaDBDialect {
|
||||||
|
|
||||||
public MariaDB53Dialect() {
|
public MariaDB53Dialect() {
|
||||||
super(530);
|
super( DatabaseVersion.make( 5, 3 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.query.CastType;
|
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
import org.hibernate.sql.ast.SqlAstTranslatorFactory;
|
||||||
@ -35,36 +34,38 @@
|
|||||||
*/
|
*/
|
||||||
public class MariaDBDialect extends MySQLDialect {
|
public class MariaDBDialect extends MySQLDialect {
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
public MariaDBDialect() {
|
public MariaDBDialect() {
|
||||||
this(500);
|
this( DatabaseVersion.make( 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MariaDBDialect(DialectResolutionInfo info) {
|
public MariaDBDialect(DialectResolutionInfo info) {
|
||||||
this(
|
this( info.makeCopy(), getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) ) );
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
|
||||||
getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) )
|
|
||||||
);
|
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MariaDBDialect(int version) {
|
public MariaDBDialect(DatabaseVersion version) {
|
||||||
// Let's be conservative and assume people use a 4 byte character set
|
// Let's be conservative and assume people use a 4 byte character set
|
||||||
this( version, 4 );
|
this( version, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MariaDBDialect(int version, int characterSetBytesPerCharacter) {
|
public MariaDBDialect(DatabaseVersion version, int characterSetBytesPerCharacter) {
|
||||||
super( version < 530 ? 500 : 570, characterSetBytesPerCharacter );
|
super(
|
||||||
|
version.isBefore( 5, 3 )
|
||||||
|
? DatabaseVersion.make( 5 )
|
||||||
|
: DatabaseVersion.make( 5, 7 ),
|
||||||
|
characterSetBytesPerCharacter
|
||||||
|
);
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getMaxVarcharLen() {
|
protected int getMaxVarcharLen() {
|
||||||
return getMySQLVersion() < 500 ? 255 : 65_534;
|
return getMySQLVersion().isBefore( 5 ) ? 255 : 65_534;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +78,7 @@ public NationalizationSupport getNationalizationSupport() {
|
|||||||
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
||||||
super.initializeFunctionRegistry(queryEngine);
|
super.initializeFunctionRegistry(queryEngine);
|
||||||
|
|
||||||
if ( getVersion() >= 1020 ) {
|
if ( getVersion().isSince( 10, 2 ) ) {
|
||||||
queryEngine.getSqmFunctionRegistry().registerNamed(
|
queryEngine.getSqmFunctionRegistry().registerNamed(
|
||||||
"json_valid",
|
"json_valid",
|
||||||
queryEngine.getTypeConfiguration()
|
queryEngine.getTypeConfiguration()
|
||||||
@ -100,12 +101,12 @@ protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsWindowFunctions() {
|
public boolean supportsWindowFunctions() {
|
||||||
return getVersion() >= 1020;
|
return getVersion().isSince( 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsColumnCheck() {
|
public boolean supportsColumnCheck() {
|
||||||
return getVersion() >= 1020;
|
return getVersion().isSince( 10, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -115,17 +116,17 @@ protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsBeforeConstraintName() {
|
public boolean supportsIfExistsBeforeConstraintName() {
|
||||||
return getVersion() >= 1000;
|
return getVersion().isSince( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsAfterAlterTable() {
|
public boolean supportsIfExistsAfterAlterTable() {
|
||||||
return getVersion() >= 1050;
|
return getVersion().isSince( 10, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
return getVersion() < 1030
|
return getVersion().isBefore( 10, 3 )
|
||||||
? super.getSequenceSupport()
|
? super.getSequenceSupport()
|
||||||
: MariaDBSequenceSupport.INSTANCE;
|
: MariaDBSequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -147,17 +148,17 @@ public SequenceInformationExtractor getSequenceInformationExtractor() {
|
|||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
//only supported on MySQL and as of 10.6
|
//only supported on MySQL and as of 10.6
|
||||||
return getVersion() >= 1060;
|
return getVersion().isSince( 10, 6 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getVersion() >= 1030;
|
return getVersion().isSince( 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsWait() {
|
public boolean supportsWait() {
|
||||||
return getVersion() >= 1030;
|
return getVersion().isSince( 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,6 +120,6 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsWindowFunctions() {
|
private boolean supportsWindowFunctions() {
|
||||||
return getDialect().getVersion() >= 1020;
|
return getDialect().getVersion().isSince( 10, 2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class MySQL55Dialect extends MySQLDialect {
|
public class MySQL55Dialect extends MySQLDialect {
|
||||||
|
|
||||||
public MySQL55Dialect() {
|
public MySQL55Dialect() {
|
||||||
super(550);
|
super( DatabaseVersion.make( 5, 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
public class MySQL57Dialect extends MySQLDialect {
|
public class MySQL57Dialect extends MySQLDialect {
|
||||||
|
|
||||||
public MySQL57Dialect() {
|
public MySQL57Dialect() {
|
||||||
super(570);
|
super( DatabaseVersion.make( 5, 7 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class MySQL5Dialect extends MySQLDialect {
|
public class MySQL5Dialect extends MySQLDialect {
|
||||||
|
|
||||||
public MySQL5Dialect() {
|
public MySQL5Dialect() {
|
||||||
super(500);
|
super( DatabaseVersion.make( 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
public class MySQL8Dialect extends MySQLDialect {
|
public class MySQL8Dialect extends MySQLDialect {
|
||||||
|
|
||||||
public MySQL8Dialect() {
|
public MySQL8Dialect() {
|
||||||
super(800);
|
super( DatabaseVersion.make( 8 ) );
|
||||||
|
|
||||||
// MySQL doesn't add the new reserved keywords to their JDBC driver to preserve backward compatibility.
|
// MySQL doesn't add the new reserved keywords to their JDBC driver to preserve backward compatibility.
|
||||||
|
|
||||||
|
@ -6,20 +6,18 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
|
||||||
import org.hibernate.dialect.function.FieldFunction;
|
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
|
||||||
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
|
||||||
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
|
||||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
|
||||||
import org.hibernate.query.CastType;
|
|
||||||
import org.hibernate.query.IntervalType;
|
|
||||||
import org.hibernate.query.NullOrdering;
|
|
||||||
import org.hibernate.PessimisticLockException;
|
import org.hibernate.PessimisticLockException;
|
||||||
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.cfg.Environment;
|
import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.dialect.function.CommonFunctionFactory;
|
import org.hibernate.dialect.function.CommonFunctionFactory;
|
||||||
|
import org.hibernate.dialect.function.FieldFunction;
|
||||||
import org.hibernate.dialect.hint.IndexQueryHintHandler;
|
import org.hibernate.dialect.hint.IndexQueryHintHandler;
|
||||||
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
import org.hibernate.dialect.identity.IdentityColumnSupport;
|
||||||
import org.hibernate.dialect.identity.MySQLIdentityColumnSupport;
|
import org.hibernate.dialect.identity.MySQLIdentityColumnSupport;
|
||||||
@ -31,6 +29,10 @@
|
|||||||
import org.hibernate.dialect.unique.UniqueDelegate;
|
import org.hibernate.dialect.unique.UniqueDelegate;
|
||||||
import org.hibernate.engine.jdbc.Size;
|
import org.hibernate.engine.jdbc.Size;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
|
||||||
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.exception.LockAcquisitionException;
|
import org.hibernate.exception.LockAcquisitionException;
|
||||||
import org.hibernate.exception.LockTimeoutException;
|
import org.hibernate.exception.LockTimeoutException;
|
||||||
@ -39,8 +41,12 @@
|
|||||||
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
import org.hibernate.exception.spi.ViolatedConstraintNameExtractor;
|
||||||
import org.hibernate.internal.util.JdbcExceptionHelper;
|
import org.hibernate.internal.util.JdbcExceptionHelper;
|
||||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||||
|
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||||
import org.hibernate.metamodel.mapping.SqlExpressable;
|
import org.hibernate.metamodel.mapping.SqlExpressable;
|
||||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
|
import org.hibernate.query.CastType;
|
||||||
|
import org.hibernate.query.IntervalType;
|
||||||
|
import org.hibernate.query.NullOrdering;
|
||||||
import org.hibernate.query.TemporalUnit;
|
import org.hibernate.query.TemporalUnit;
|
||||||
import org.hibernate.query.spi.QueryEngine;
|
import org.hibernate.query.spi.QueryEngine;
|
||||||
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
import org.hibernate.query.sqm.mutation.internal.temptable.AfterUseAction;
|
||||||
@ -67,12 +73,6 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.NullJdbcType;
|
import org.hibernate.type.descriptor.jdbc.NullJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.CallableStatement;
|
|
||||||
import java.sql.DatabaseMetaData;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
@ -86,28 +86,25 @@ public class MySQLDialect extends Dialect {
|
|||||||
|
|
||||||
private final UniqueDelegate uniqueDelegate;
|
private final UniqueDelegate uniqueDelegate;
|
||||||
private final MySQLStorageEngine storageEngine;
|
private final MySQLStorageEngine storageEngine;
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
private final int characterSetBytesPerCharacter;
|
private final int characterSetBytesPerCharacter;
|
||||||
private final SizeStrategy sizeStrategy;
|
private final SizeStrategy sizeStrategy;
|
||||||
|
|
||||||
public MySQLDialect(DialectResolutionInfo info) {
|
public MySQLDialect(DialectResolutionInfo info) {
|
||||||
this(
|
this( info.makeCopy(), getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) ) );
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
|
||||||
getCharacterSetBytesPerCharacter( info.unwrap( DatabaseMetaData.class ) )
|
|
||||||
);
|
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySQLDialect() {
|
public MySQLDialect() {
|
||||||
this( 500 );
|
this( DatabaseVersion.make( 5, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySQLDialect(int version) {
|
public MySQLDialect(DatabaseVersion version) {
|
||||||
// Let's be conservative and assume people use a 4 byte character set
|
// Let's be conservative and assume people use a 4 byte character set
|
||||||
this( version, 4 );
|
this( version, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
public MySQLDialect(int version, int characterSetBytesPerCharacter) {
|
public MySQLDialect(DatabaseVersion version, int characterSetBytesPerCharacter) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.characterSetBytesPerCharacter = characterSetBytesPerCharacter;
|
this.characterSetBytesPerCharacter = characterSetBytesPerCharacter;
|
||||||
@ -133,7 +130,7 @@ else if( "myisam".equalsIgnoreCase( storageEngine ) ) {
|
|||||||
|
|
||||||
registerColumnType( Types.NUMERIC, "decimal($p,$s)" ); //it's just a synonym
|
registerColumnType( Types.NUMERIC, "decimal($p,$s)" ); //it's just a synonym
|
||||||
|
|
||||||
if ( getMySQLVersion() < 570) {
|
if ( getMySQLVersion().isBefore( 5, 7 ) ) {
|
||||||
registerColumnType( Types.TIMESTAMP, "datetime" );
|
registerColumnType( Types.TIMESTAMP, "datetime" );
|
||||||
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
|
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
|
||||||
}
|
}
|
||||||
@ -183,7 +180,7 @@ else if( "myisam".equalsIgnoreCase( storageEngine ) ) {
|
|||||||
registerColumnType( Types.NCLOB, maxLobLen, "text" );
|
registerColumnType( Types.NCLOB, maxLobLen, "text" );
|
||||||
registerColumnType( Types.NCLOB, maxTinyLobLen, "tinytext" );
|
registerColumnType( Types.NCLOB, maxTinyLobLen, "tinytext" );
|
||||||
|
|
||||||
if ( getMySQLVersion() >= 570) {
|
if ( getMySQLVersion().isBefore( 5, 7 ) ) {
|
||||||
// MySQL 5.7 brings JSON native support with a dedicated datatype
|
// MySQL 5.7 brings JSON native support with a dedicated datatype
|
||||||
// https://dev.mysql.com/doc/refman/5.7/en/json.html
|
// https://dev.mysql.com/doc/refman/5.7/en/json.html
|
||||||
registerColumnType( SqlTypes.JSON, "json");
|
registerColumnType( SqlTypes.JSON, "json");
|
||||||
@ -257,7 +254,7 @@ protected static int getCharacterSetBytesPerCharacter(DatabaseMetaData databaseM
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected int getMaxVarcharLen() {
|
protected int getMaxVarcharLen() {
|
||||||
if ( getMySQLVersion() < 500 ) {
|
if ( getMySQLVersion().isBefore( 5 ) ) {
|
||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -286,11 +283,11 @@ public String getNullColumnString(String columnType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMySQLVersion() {
|
public DatabaseVersion getMySQLVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,7 +389,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.format_dateFormat( queryEngine );
|
CommonFunctionFactory.format_dateFormat( queryEngine );
|
||||||
CommonFunctionFactory.makedateMaketime( queryEngine );
|
CommonFunctionFactory.makedateMaketime( queryEngine );
|
||||||
|
|
||||||
if ( getMySQLVersion() < 570 ) {
|
if ( getMySQLVersion().isBefore( 5, 7 ) ) {
|
||||||
CommonFunctionFactory.sysdateParens( queryEngine );
|
CommonFunctionFactory.sysdateParens( queryEngine );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -411,7 +408,7 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
final JdbcTypeRegistry jdbcTypeRegistry = typeContributions.getTypeConfiguration()
|
||||||
.getJdbcTypeDescriptorRegistry();
|
.getJdbcTypeDescriptorRegistry();
|
||||||
|
|
||||||
if ( getMySQLVersion() >= 570) {
|
if ( getMySQLVersion().isSince( 5, 7 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( SqlTypes.JSON, JsonJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( SqlTypes.JSON, JsonJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -480,7 +477,7 @@ public int getFloatPrecision() {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String currentTimestamp() {
|
public String currentTimestamp() {
|
||||||
return getMySQLVersion() < 570 ? super.currentTimestamp() : "current_timestamp(6)";
|
return getMySQLVersion().isBefore( 5, 7 ) ? super.currentTimestamp() : "current_timestamp(6)";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -552,7 +549,7 @@ public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalT
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsUnionAll() {
|
public boolean supportsUnionAll() {
|
||||||
return getMySQLVersion() >= 500;
|
return getMySQLVersion().isSince( 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -567,7 +564,7 @@ public boolean supportsColumnCheck() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQueryHintString(String query, String hints) {
|
public String getQueryHintString(String query, String hints) {
|
||||||
return getMySQLVersion() < 500
|
return getMySQLVersion().isBefore( 5 )
|
||||||
? super.getQueryHintString( query, hints )
|
? super.getQueryHintString( query, hints )
|
||||||
: IndexQueryHintHandler.INSTANCE.addQueryHints( query, hints );
|
: IndexQueryHintHandler.INSTANCE.addQueryHints( query, hints );
|
||||||
}
|
}
|
||||||
@ -581,7 +578,7 @@ public SequenceSupport getSequenceSupport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
||||||
return getMySQLVersion() < 500 ? super.getViolatedConstraintNameExtractor() : EXTRACTOR;
|
return getMySQLVersion().isBefore( 5 ) ? super.getViolatedConstraintNameExtractor() : EXTRACTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final ViolatedConstraintNameExtractor EXTRACTOR =
|
private static final ViolatedConstraintNameExtractor EXTRACTOR =
|
||||||
@ -937,7 +934,7 @@ public boolean supportsCascadeDelete() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTableTypeString() {
|
public String getTableTypeString() {
|
||||||
String engineKeyword = getMySQLVersion() < 500 ? "type" : "engine";
|
String engineKeyword = getMySQLVersion().isBefore( 5 ) ? "type" : "engine";
|
||||||
return storageEngine.getTableTypeString( engineKeyword );
|
return storageEngine.getTableTypeString( engineKeyword );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -952,7 +949,7 @@ public boolean dropConstraints() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
protected MySQLStorageEngine getDefaultMySQLStorageEngine() {
|
||||||
return getMySQLVersion() < 550 ? MyISAMStorageEngine.INSTANCE : InnoDBStorageEngine.INSTANCE;
|
return getMySQLVersion().isBefore( 5, 5 ) ? MyISAMStorageEngine.INSTANCE : InnoDBStorageEngine.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1132,17 +1129,17 @@ public boolean supportsOffsetInSubquery() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsWindowFunctions() {
|
public boolean supportsWindowFunctions() {
|
||||||
return getMySQLVersion() >= 802;
|
return getMySQLVersion().isSince( 8, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
return getMySQLVersion() >= 800;
|
return getMySQLVersion().isSince( 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getMySQLVersion() >= 800;
|
return getMySQLVersion().isSince( 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1157,11 +1154,11 @@ public RowLockStrategy getWriteRowLockStrategy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean supportsForShare() {
|
boolean supportsForShare() {
|
||||||
return getMySQLVersion() >= 800;
|
return getMySQLVersion().isSince( 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean supportsAliasLocks() {
|
boolean supportsAliasLocks() {
|
||||||
return getMySQLVersion() >= 800;
|
return getMySQLVersion().isSince( 8 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanEx
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getForShare(int timeoutMillis) {
|
protected String getForShare(int timeoutMillis) {
|
||||||
return getDialect().getVersion() >= 800 ? " for share" : " lock in share mode";
|
return getDialect().getVersion().isSince( 8 ) ? " for share" : " lock in share mode";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
|
protected boolean shouldEmulateFetchClause(QueryPart queryPart) {
|
||||||
@ -117,7 +117,7 @@ public boolean supportsRowValueConstructorSyntaxInSet() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsRowValueConstructorSyntaxInInList() {
|
public boolean supportsRowValueConstructorSyntaxInInList() {
|
||||||
return getDialect().getVersion() >= 570;
|
return getDialect().getVersion().isSince( 5, 7 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,6 @@
|
|||||||
public class Oracle10gDialect extends OracleDialect {
|
public class Oracle10gDialect extends OracleDialect {
|
||||||
|
|
||||||
public Oracle10gDialect() {
|
public Oracle10gDialect() {
|
||||||
super( 1000 );
|
super( DatabaseVersion.make( 10 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,6 @@
|
|||||||
public class Oracle12cDialect extends OracleDialect {
|
public class Oracle12cDialect extends OracleDialect {
|
||||||
|
|
||||||
public Oracle12cDialect() {
|
public Oracle12cDialect() {
|
||||||
super( 1200 );
|
super( DatabaseVersion.make( 12 ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
public class Oracle8iDialect extends OracleDialect {
|
public class Oracle8iDialect extends OracleDialect {
|
||||||
|
|
||||||
public Oracle8iDialect() {
|
public Oracle8iDialect() {
|
||||||
super( 800 );
|
super( DatabaseVersion.make( 8 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
public class Oracle9iDialect extends OracleDialect {
|
public class Oracle9iDialect extends OracleDialect {
|
||||||
|
|
||||||
public Oracle9iDialect() {
|
public Oracle9iDialect() {
|
||||||
super( 900 );
|
super( DatabaseVersion.make( 9 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.CallableStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.QueryTimeoutException;
|
import org.hibernate.QueryTimeoutException;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
@ -69,18 +77,15 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.ObjectNullAsNullTypeJdbcType;
|
import org.hibernate.type.descriptor.jdbc.ObjectNullAsNullTypeJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
import java.sql.CallableStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.sql.Types;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
import static org.hibernate.query.TemporalUnit.*;
|
import static org.hibernate.query.TemporalUnit.DAY;
|
||||||
|
import static org.hibernate.query.TemporalUnit.HOUR;
|
||||||
|
import static org.hibernate.query.TemporalUnit.MINUTE;
|
||||||
|
import static org.hibernate.query.TemporalUnit.MONTH;
|
||||||
|
import static org.hibernate.query.TemporalUnit.SECOND;
|
||||||
|
import static org.hibernate.query.TemporalUnit.YEAR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A dialect for Oracle 8i and above.
|
* A dialect for Oracle 8i and above.
|
||||||
@ -100,18 +105,18 @@ public class OracleDialect extends Dialect {
|
|||||||
public static final String PREFER_LONG_RAW = "hibernate.dialect.oracle.prefer_long_raw";
|
public static final String PREFER_LONG_RAW = "hibernate.dialect.oracle.prefer_long_raw";
|
||||||
|
|
||||||
private final LimitHandler limitHandler;
|
private final LimitHandler limitHandler;
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
public OracleDialect(DialectResolutionInfo info) {
|
public OracleDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OracleDialect() {
|
public OracleDialect() {
|
||||||
this( 800 );
|
this( DatabaseVersion.make( 8, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public OracleDialect(int version) {
|
public OracleDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
@ -129,7 +134,7 @@ public OracleDialect(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +183,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
|
CommonFunctionFactory.regrLinearRegressionAggregates( queryEngine );
|
||||||
CommonFunctionFactory.bitLength_pattern( queryEngine, "vsize(?1)*8" );
|
CommonFunctionFactory.bitLength_pattern( queryEngine, "vsize(?1)*8" );
|
||||||
|
|
||||||
if ( getVersion() < 900 ) {
|
if ( getVersion().isBefore( 9 ) ) {
|
||||||
queryEngine.getSqmFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
|
queryEngine.getSqmFunctionRegistry().register( "coalesce", new NvlCoalesceEmulation() );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -207,7 +212,7 @@ protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String currentDate() {
|
public String currentDate() {
|
||||||
return getVersion() < 900 ? currentTimestamp() : "current_date";
|
return getVersion().isBefore( 9 ) ? currentTimestamp() : "current_date";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -217,7 +222,7 @@ public String currentTime() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String currentTimestamp() {
|
public String currentTimestamp() {
|
||||||
return getVersion() < 900 ? "sysdate" : currentTimestampWithTimeZone();
|
return getVersion().isBefore( 9 ) ? "sysdate" : currentTimestampWithTimeZone();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -227,12 +232,12 @@ public String currentLocalTime() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String currentLocalTimestamp() {
|
public String currentLocalTimestamp() {
|
||||||
return getVersion() < 900 ? currentTimestamp() : "localtimestamp";
|
return getVersion().isBefore( 9 ) ? currentTimestamp() : "localtimestamp";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String currentTimestampWithTimeZone() {
|
public String currentTimestampWithTimeZone() {
|
||||||
return getVersion() < 900 ? currentTimestamp() : "current_timestamp";
|
return getVersion().isBefore( 9 ) ? currentTimestamp() : "current_timestamp";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -519,7 +524,7 @@ private void extractField(
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void registerCharacterTypeMappings() {
|
protected void registerCharacterTypeMappings() {
|
||||||
if ( getVersion() < 900) {
|
if ( getVersion().isBefore( 9 ) ) {
|
||||||
registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
|
registerColumnType( Types.VARCHAR, 4000, "varchar2($l)" );
|
||||||
registerColumnType( Types.VARCHAR, "clob" );
|
registerColumnType( Types.VARCHAR, "clob" );
|
||||||
}
|
}
|
||||||
@ -549,7 +554,7 @@ protected void registerNumericTypeMappings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void registerDateTimeTypeMappings() {
|
protected void registerDateTimeTypeMappings() {
|
||||||
if ( getVersion() < 900 ) {
|
if ( getVersion().isBefore( 9 ) ) {
|
||||||
registerColumnType( Types.DATE, "date" );
|
registerColumnType( Types.DATE, "date" );
|
||||||
registerColumnType( Types.TIME, "date" );
|
registerColumnType( Types.TIME, "date" );
|
||||||
registerColumnType( Types.TIMESTAMP, "date" );
|
registerColumnType( Types.TIMESTAMP, "date" );
|
||||||
@ -567,7 +572,7 @@ protected void registerDateTimeTypeMappings() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeZoneSupport getTimeZoneSupport() {
|
public TimeZoneSupport getTimeZoneSupport() {
|
||||||
return getVersion() >= 900 ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
return getVersion().isSince( 9 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerBinaryTypeMappings() {
|
protected void registerBinaryTypeMappings() {
|
||||||
@ -579,7 +584,7 @@ protected void registerBinaryTypeMappings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void registerExtendedTypeMappings() {
|
protected void registerExtendedTypeMappings() {
|
||||||
if ( getVersion() >= 1000 ) {
|
if ( getVersion().isSince( 10 ) ) {
|
||||||
registerColumnType( SqlTypes.GEOMETRY, "MDSYS.SDO_GEOMETRY" );
|
registerColumnType( SqlTypes.GEOMETRY, "MDSYS.SDO_GEOMETRY" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -591,7 +596,7 @@ protected void registerDefaultProperties() {
|
|||||||
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
|
getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" );
|
||||||
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );
|
||||||
|
|
||||||
if ( getVersion() < 1200 ) {
|
if ( getVersion().isBefore( 12 ) ) {
|
||||||
// Oracle driver reports to support getGeneratedKeys(), but they only
|
// Oracle driver reports to support getGeneratedKeys(), but they only
|
||||||
// support the version taking an array of the names of the columns to
|
// support the version taking an array of the names of the columns to
|
||||||
// be returned (via its RETURNING clause). No other driver seems to
|
// be returned (via its RETURNING clause). No other driver seems to
|
||||||
@ -661,7 +666,7 @@ public boolean supportsBitType() {
|
|||||||
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
public void contributeTypes(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||||
super.contributeTypes( typeContributions, serviceRegistry );
|
super.contributeTypes( typeContributions, serviceRegistry );
|
||||||
|
|
||||||
if ( getVersion() >= 1200 ) {
|
if ( getVersion().isSince( 12 ) ) {
|
||||||
// account for Oracle's deprecated support for LONGVARBINARY
|
// account for Oracle's deprecated support for LONGVARBINARY
|
||||||
// prefer BLOB, unless the user explicitly opts out
|
// prefer BLOB, unless the user explicitly opts out
|
||||||
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
boolean preferLong = serviceRegistry.getService( ConfigurationService.class ).getSetting(
|
||||||
@ -709,7 +714,7 @@ public String getNativeIdentifierGeneratorStrategy() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IdentityColumnSupport getIdentityColumnSupport() {
|
public IdentityColumnSupport getIdentityColumnSupport() {
|
||||||
return getVersion() < 1200
|
return getVersion().isBefore( 12 )
|
||||||
? super.getIdentityColumnSupport()
|
? super.getIdentityColumnSupport()
|
||||||
: new Oracle12cIdentityColumnSupport();
|
: new Oracle12cIdentityColumnSupport();
|
||||||
}
|
}
|
||||||
@ -721,7 +726,7 @@ public LimitHandler getLimitHandler() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSelectClauseNullString(int sqlType) {
|
public String getSelectClauseNullString(int sqlType) {
|
||||||
if ( getVersion() >= 900 ) {
|
if ( getVersion().isSince( 9 ) ) {
|
||||||
return super.getSelectClauseNullString(sqlType);
|
return super.getSelectClauseNullString(sqlType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -742,7 +747,7 @@ public String getSelectClauseNullString(int sqlType) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCurrentTimestampSelectString() {
|
public String getCurrentTimestampSelectString() {
|
||||||
return getVersion() < 900
|
return getVersion().isBefore( 9 )
|
||||||
? "select sysdate from dual"
|
? "select sysdate from dual"
|
||||||
: "select systimestamp from dual";
|
: "select systimestamp from dual";
|
||||||
}
|
}
|
||||||
@ -1042,7 +1047,7 @@ public boolean supportsOffsetInSubquery() {
|
|||||||
public boolean supportsFetchClause(FetchClauseType type) {
|
public boolean supportsFetchClause(FetchClauseType type) {
|
||||||
// Until 12.2 there was a bug in the Oracle query rewriter causing ORA-00918
|
// Until 12.2 there was a bug in the Oracle query rewriter causing ORA-00918
|
||||||
// when the query contains duplicate implicit aliases in the select clause
|
// when the query contains duplicate implicit aliases in the select clause
|
||||||
return getVersion() >= 1202;
|
return getVersion().isSince( 12, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1052,12 +1057,12 @@ public boolean supportsWindowFunctions() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getVersion() >= 900;
|
return getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
return getVersion() >= 1000;
|
return getVersion().isSince( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,7 +6,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
@ -368,7 +367,7 @@ protected void renderSelectTupleComparison(
|
|||||||
@Override
|
@Override
|
||||||
protected void visitCaseSearchedExpression(CaseSearchedExpression caseSearchedExpression, boolean inSelect) {
|
protected void visitCaseSearchedExpression(CaseSearchedExpression caseSearchedExpression, boolean inSelect) {
|
||||||
// Oracle did not add support for CASE until 9i
|
// Oracle did not add support for CASE until 9i
|
||||||
if ( getDialect().getVersion() < 900 ) {
|
if ( getDialect().getVersion().isBefore( 9 ) ) {
|
||||||
visitDecodeCaseSearchedExpression( caseSearchedExpression );
|
visitDecodeCaseSearchedExpression( caseSearchedExpression );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -400,7 +399,7 @@ protected boolean supportsRowValueConstructorSyntax() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportsRowValueConstructorSyntaxInInList() {
|
protected boolean supportsRowValueConstructorSyntaxInInList() {
|
||||||
return getDialect().getVersion() >= 820;
|
return getDialect().getVersion().isSince( 8, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -410,7 +409,7 @@ protected boolean supportsRowValueConstructorSyntaxInQuantifiedPredicates() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean supportsRowValueConstructorSyntaxInInSubQuery() {
|
protected boolean supportsRowValueConstructorSyntaxInInSubQuery() {
|
||||||
return getDialect().getVersion() >= 900;
|
return getDialect().getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
public class PostgreSQL81Dialect extends PostgreSQLDialect {
|
public class PostgreSQL81Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL81Dialect() {
|
public PostgreSQL81Dialect() {
|
||||||
super(810);
|
super( DatabaseVersion.make( 8, 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class PostgreSQL82Dialect extends PostgreSQLDialect {
|
public class PostgreSQL82Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL82Dialect() {
|
public PostgreSQL82Dialect() {
|
||||||
super(820);
|
super( DatabaseVersion.make( 8, 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
public class PostgreSQL91Dialect extends PostgreSQLDialect {
|
public class PostgreSQL91Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL91Dialect() {
|
public PostgreSQL91Dialect() {
|
||||||
super(910);
|
super( DatabaseVersion.make( 9, 1 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
public class PostgreSQL92Dialect extends PostgreSQLDialect {
|
public class PostgreSQL92Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL92Dialect() {
|
public PostgreSQL92Dialect() {
|
||||||
super(920);
|
super( DatabaseVersion.make( 9, 2 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
public class PostgreSQL93Dialect extends PostgreSQLDialect {
|
public class PostgreSQL93Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL93Dialect() {
|
public PostgreSQL93Dialect() {
|
||||||
super(930);
|
super( DatabaseVersion.make( 9, 3 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
public class PostgreSQL94Dialect extends PostgreSQLDialect {
|
public class PostgreSQL94Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL94Dialect() {
|
public PostgreSQL94Dialect() {
|
||||||
super(940);
|
super( DatabaseVersion.make( 9, 4 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
public class PostgreSQL95Dialect extends PostgreSQLDialect {
|
public class PostgreSQL95Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL95Dialect() {
|
public PostgreSQL95Dialect() {
|
||||||
super(950);
|
super( DatabaseVersion.make( 9, 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
public class PostgreSQL9Dialect extends PostgreSQLDialect {
|
public class PostgreSQL9Dialect extends PostgreSQLDialect {
|
||||||
|
|
||||||
public PostgreSQL9Dialect() {
|
public PostgreSQL9Dialect() {
|
||||||
super(900);
|
super( DatabaseVersion.make( 9 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
@ -79,8 +77,14 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
import org.hibernate.type.descriptor.jdbc.UUIDJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
import static org.hibernate.query.TemporalUnit.*;
|
import static org.hibernate.query.TemporalUnit.DAY;
|
||||||
|
import static org.hibernate.query.TemporalUnit.EPOCH;
|
||||||
|
import static org.hibernate.query.TemporalUnit.MONTH;
|
||||||
|
import static org.hibernate.query.TemporalUnit.QUARTER;
|
||||||
|
import static org.hibernate.query.TemporalUnit.YEAR;
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsDate;
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsDate;
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTime;
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTime;
|
||||||
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithMicros;
|
import static org.hibernate.type.descriptor.DateTimeUtils.appendAsTimestampWithMicros;
|
||||||
@ -94,27 +98,24 @@ public class PostgreSQLDialect extends Dialect {
|
|||||||
|
|
||||||
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
private static final PostgreSQLIdentityColumnSupport IDENTITY_COLUMN_SUPPORT = new PostgreSQLIdentityColumnSupport();
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
private final PostgreSQLDriverKind driverKind;
|
private final PostgreSQLDriverKind driverKind;
|
||||||
|
|
||||||
public PostgreSQLDialect(DialectResolutionInfo info) {
|
public PostgreSQLDialect(DialectResolutionInfo info) {
|
||||||
this(
|
this( info.makeCopy(), PostgreSQLDriverKind.determineKind( info ) );
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
|
||||||
PostgreSQLDriverKind.determineKind( info )
|
|
||||||
);
|
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public PostgreSQLDialect() {
|
public PostgreSQLDialect() {
|
||||||
this( 800 );
|
this( DatabaseVersion.make( 8, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public PostgreSQLDialect(int version) {
|
public PostgreSQLDialect(DatabaseVersion version) {
|
||||||
// Assume PgJDBC by default
|
// Assume PgJDBC by default
|
||||||
this( version, PostgreSQLDriverKind.PG_JDBC );
|
this( version, PostgreSQLDriverKind.PG_JDBC );
|
||||||
}
|
}
|
||||||
|
|
||||||
public PostgreSQLDialect(int version, PostgreSQLDriverKind driverKind) {
|
public PostgreSQLDialect(DatabaseVersion version, PostgreSQLDriverKind driverKind) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.driverKind = driverKind;
|
this.driverKind = driverKind;
|
||||||
@ -142,12 +143,12 @@ public PostgreSQLDialect(int version, PostgreSQLDriverKind driverKind) {
|
|||||||
registerColumnType( SqlTypes.INET, "inet" );
|
registerColumnType( SqlTypes.INET, "inet" );
|
||||||
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($s)" );
|
registerColumnType( SqlTypes.INTERVAL_SECOND, "interval second($s)" );
|
||||||
|
|
||||||
if ( getVersion() >= 820 ) {
|
if ( getVersion().isSince( 8, 2 ) ) {
|
||||||
registerColumnType( SqlTypes.UUID, "uuid" );
|
registerColumnType( SqlTypes.UUID, "uuid" );
|
||||||
|
|
||||||
if ( getVersion() >= 920 ) {
|
if ( getVersion().isSince( 9, 2 ) ) {
|
||||||
// Prefer jsonb if possible
|
// Prefer jsonb if possible
|
||||||
if ( getVersion() >= 940 ) {
|
if ( getVersion().isSince( 9, 4 ) ) {
|
||||||
registerColumnType( SqlTypes.JSON, "jsonb" );
|
registerColumnType( SqlTypes.JSON, "jsonb" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -204,7 +205,7 @@ public JdbcType resolveSqlTypeDescriptor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,7 +412,7 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
"(position(?1 in substring(?2 from ?3))+(?3)-1)"
|
"(position(?1 in substring(?2 from ?3))+(?3)-1)"
|
||||||
).setArgumentListSignature("(pattern, string[, start])");
|
).setArgumentListSignature("(pattern, string[, start])");
|
||||||
|
|
||||||
if ( getVersion() >= 940 ) {
|
if ( getVersion().isSince( 9, 4 ) ) {
|
||||||
CommonFunctionFactory.makeDateTimeTimestamp( queryEngine );
|
CommonFunctionFactory.makeDateTimeTimestamp( queryEngine );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -430,37 +431,37 @@ public String getCurrentSchemaCommand() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsBeforeTableName() {
|
public boolean supportsIfExistsBeforeTableName() {
|
||||||
return getVersion() >= 820;
|
return getVersion().isSince( 8, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsBeforeConstraintName() {
|
public boolean supportsIfExistsBeforeConstraintName() {
|
||||||
return getVersion() >= 900;
|
return getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsAfterAlterTable() {
|
public boolean supportsIfExistsAfterAlterTable() {
|
||||||
return getVersion() >= 920;
|
return getVersion().isSince( 9, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsValuesList() {
|
public boolean supportsValuesList() {
|
||||||
return getVersion() >= 820;
|
return getVersion().isSince( 8, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsPartitionBy() {
|
public boolean supportsPartitionBy() {
|
||||||
return getVersion() >= 910;
|
return getVersion().isSince( 9, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNonQueryWithCTE() {
|
public boolean supportsNonQueryWithCTE() {
|
||||||
return getVersion() >= 910;
|
return getVersion().isSince( 9, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
return getVersion() < 820
|
return getVersion().isBefore( 8, 2 )
|
||||||
? PostgreSQLSequenceSupport.LEGACY_INSTANCE
|
? PostgreSQLSequenceSupport.LEGACY_INSTANCE
|
||||||
: PostgreSQLSequenceSupport.INSTANCE;
|
: PostgreSQLSequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -477,7 +478,7 @@ public String getQuerySequencesString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LimitHandler getLimitHandler() {
|
public LimitHandler getLimitHandler() {
|
||||||
return getVersion() < 840
|
return getVersion().isBefore( 8, 4 )
|
||||||
? LimitOffsetLimitHandler.INSTANCE
|
? LimitOffsetLimitHandler.INSTANCE
|
||||||
: OffsetFetchLimitHandler.INSTANCE;
|
: OffsetFetchLimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
@ -946,7 +947,7 @@ public String getForUpdateSkipLockedString(String aliases) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getVersion() >= 810;
|
return getVersion().isSince( 8, 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -956,7 +957,7 @@ public boolean supportsWait() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
return getVersion() >= 950;
|
return getVersion().isSince( 9, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -973,12 +974,12 @@ public boolean supportsWindowFunctions() {
|
|||||||
public boolean supportsFetchClause(FetchClauseType type) {
|
public boolean supportsFetchClause(FetchClauseType type) {
|
||||||
switch ( type ) {
|
switch ( type ) {
|
||||||
case ROWS_ONLY:
|
case ROWS_ONLY:
|
||||||
return getVersion() >= 840;
|
return getVersion().isSince( 8, 4 );
|
||||||
case PERCENT_ONLY:
|
case PERCENT_ONLY:
|
||||||
case PERCENT_WITH_TIES:
|
case PERCENT_WITH_TIES:
|
||||||
return false;
|
return false;
|
||||||
case ROWS_WITH_TIES:
|
case ROWS_WITH_TIES:
|
||||||
return getVersion() >= 1300;
|
return getVersion().isSince( 13 );
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -991,13 +992,13 @@ public RowLockStrategy getWriteRowLockStrategy() {
|
|||||||
@Override
|
@Override
|
||||||
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
public void augmentRecognizedTableTypes(List<String> tableTypesList) {
|
||||||
super.augmentRecognizedTableTypes( tableTypesList );
|
super.augmentRecognizedTableTypes( tableTypesList );
|
||||||
if ( getVersion() >= 930 ) {
|
if ( getVersion().isSince( 9, 3 ) ) {
|
||||||
tableTypesList.add( "MATERIALIZED VIEW" );
|
tableTypesList.add( "MATERIALIZED VIEW" );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
PostgreSQL 10 and later adds support for Partition table.
|
PostgreSQL 10 and later adds support for Partition table.
|
||||||
*/
|
*/
|
||||||
if ( getVersion() >= 1000 ) {
|
if ( getVersion().isSince( 10 ) ) {
|
||||||
tableTypesList.add( "PARTITIONED TABLE" );
|
tableTypesList.add( "PARTITIONED TABLE" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1024,10 +1025,10 @@ public void contributeTypes(TypeContributions typeContributions, ServiceRegistry
|
|||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLInetJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLInetJdbcType.INSTANCE );
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLIntervalSecondJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLIntervalSecondJdbcType.INSTANCE );
|
||||||
|
|
||||||
if ( getVersion() >= 820 ) {
|
if ( getVersion().isSince( 8, 2 ) ) {
|
||||||
// HHH-9562
|
// HHH-9562
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( UUIDJdbcType.INSTANCE );
|
||||||
if ( getVersion() >= 920 ) {
|
if ( getVersion().isSince( 9, 2 ) ) {
|
||||||
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLJsonbJdbcType.INSTANCE );
|
jdbcTypeRegistry.addDescriptorIfAbsent( PostgreSQLJsonbJdbcType.INSTANCE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ public void visitBooleanExpressionPredicate(BooleanExpressionPredicate booleanEx
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderMaterializationHint(CteMaterialization materialization) {
|
protected void renderMaterializationHint(CteMaterialization materialization) {
|
||||||
if ( getDialect().getVersion() >= 1200 ) {
|
if ( getDialect().getVersion().isSince( 12 ) ) {
|
||||||
if ( materialization == CteMaterialization.NOT_MATERIALIZED ) {
|
if ( materialization == CteMaterialization.NOT_MATERIALIZED ) {
|
||||||
appendSql( "not " );
|
appendSql( "not " );
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ protected void renderMaterializationHint(CteMaterialization materialization) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsFilterClause() {
|
public boolean supportsFilterClause() {
|
||||||
return getDialect().getVersion() >= 940;
|
return getDialect().getVersion().isSince( 9, 4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -118,7 +118,7 @@ protected void renderPartitionItem(Expression expression) {
|
|||||||
// We render an empty group instead of literals as some DBs don't support grouping by literals
|
// We render an empty group instead of literals as some DBs don't support grouping by literals
|
||||||
// Note that integer literals, which refer to select item positions, are handled in #visitGroupByClause
|
// Note that integer literals, which refer to select item positions, are handled in #visitGroupByClause
|
||||||
if ( expression instanceof Literal ) {
|
if ( expression instanceof Literal ) {
|
||||||
if ( getDialect().getVersion() >= 950 ) {
|
if ( getDialect().getVersion().isSince( 9, 5 ) ) {
|
||||||
appendSql( "()" );
|
appendSql( "()" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -129,7 +129,7 @@ protected void renderPartitionItem(Expression expression) {
|
|||||||
}
|
}
|
||||||
else if ( expression instanceof Summarization ) {
|
else if ( expression instanceof Summarization ) {
|
||||||
Summarization summarization = (Summarization) expression;
|
Summarization summarization = (Summarization) expression;
|
||||||
if ( getDialect().getVersion() >= 950 ) {
|
if ( getDialect().getVersion().isSince( 9, 5 ) ) {
|
||||||
appendSql( summarization.getKind().sqlText() );
|
appendSql( summarization.getKind().sqlText() );
|
||||||
appendSql( OPEN_PARENTHESIS );
|
appendSql( OPEN_PARENTHESIS );
|
||||||
renderCommaSeparated( summarization.getGroupings() );
|
renderCommaSeparated( summarization.getGroupings() );
|
||||||
|
@ -38,7 +38,7 @@ public PostgresPlusDialect(DialectResolutionInfo info) {
|
|||||||
super( info );
|
super( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public PostgresPlusDialect(int version) {
|
public PostgresPlusDialect(DatabaseVersion version) {
|
||||||
super( version );
|
super( version );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
public class SQLServer2005Dialect extends SQLServerDialect {
|
public class SQLServer2005Dialect extends SQLServerDialect {
|
||||||
|
|
||||||
public SQLServer2005Dialect() {
|
public SQLServer2005Dialect() {
|
||||||
super(9);
|
super( DatabaseVersion.make( 9 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class SQLServer2008Dialect extends SQLServerDialect {
|
public class SQLServer2008Dialect extends SQLServerDialect {
|
||||||
|
|
||||||
public SQLServer2008Dialect() {
|
public SQLServer2008Dialect() {
|
||||||
super(10);
|
super( DatabaseVersion.make( 10 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class SQLServer2012Dialect extends SQLServerDialect {
|
public class SQLServer2012Dialect extends SQLServerDialect {
|
||||||
|
|
||||||
public SQLServer2012Dialect() {
|
public SQLServer2012Dialect() {
|
||||||
super(11);
|
super( DatabaseVersion.make( 11 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
public class SQLServer2016Dialect extends SQLServerDialect {
|
public class SQLServer2016Dialect extends SQLServerDialect {
|
||||||
|
|
||||||
public SQLServer2016Dialect() {
|
public SQLServer2016Dialect() {
|
||||||
super(16);
|
super( DatabaseVersion.make( 16 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -80,20 +80,20 @@
|
|||||||
public class SQLServerDialect extends AbstractTransactSQLDialect {
|
public class SQLServerDialect extends AbstractTransactSQLDialect {
|
||||||
private static final int PARAM_LIST_SIZE_LIMIT = 2100;
|
private static final int PARAM_LIST_SIZE_LIMIT = 2100;
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private StandardSequenceExporter exporter;
|
private StandardSequenceExporter exporter;
|
||||||
|
|
||||||
public SQLServerDialect(DialectResolutionInfo info) {
|
public SQLServerDialect(DialectResolutionInfo info) {
|
||||||
this( info.getDatabaseMajorVersion() );
|
this( info.makeCopy() );
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLServerDialect() {
|
public SQLServerDialect() {
|
||||||
this( 8 );
|
this( DatabaseVersion.make( 8, 0 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SQLServerDialect(int version) {
|
public SQLServerDialect(DatabaseVersion version) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public SQLServerDialect(int version) {
|
|||||||
//but 'float' is double precision by default
|
//but 'float' is double precision by default
|
||||||
registerColumnType( Types.DOUBLE, "float" );
|
registerColumnType( Types.DOUBLE, "float" );
|
||||||
|
|
||||||
if ( getVersion() >= 10 ) {
|
if ( getVersion().isSince( 10 ) ) {
|
||||||
registerColumnType( Types.DATE, "date" );
|
registerColumnType( Types.DATE, "date" );
|
||||||
registerColumnType( Types.TIME, "time" );
|
registerColumnType( Types.TIME, "time" );
|
||||||
registerColumnType( Types.TIMESTAMP, "datetime2($p)" );
|
registerColumnType( Types.TIMESTAMP, "datetime2($p)" );
|
||||||
@ -109,7 +109,7 @@ public SQLServerDialect(int version) {
|
|||||||
registerColumnType( SqlTypes.GEOMETRY, "geometry" );
|
registerColumnType( SqlTypes.GEOMETRY, "geometry" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getVersion() >= 11 ) {
|
if ( getVersion().isSince( 11 ) ) {
|
||||||
exporter = new SqlServerSequenceExporter( this );
|
exporter = new SqlServerSequenceExporter( this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ public SQLServerDialect(int version) {
|
|||||||
registerColumnType( Types.NVARCHAR, 4000, "nvarchar($l)" );
|
registerColumnType( Types.NVARCHAR, 4000, "nvarchar($l)" );
|
||||||
registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
|
registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
|
||||||
|
|
||||||
if ( getVersion() < 9 ) {
|
if ( getVersion().isBefore( 9 ) ) {
|
||||||
registerColumnType( Types.VARBINARY, "image" );
|
registerColumnType( Types.VARBINARY, "image" );
|
||||||
registerColumnType( Types.VARCHAR, "text" );
|
registerColumnType( Types.VARCHAR, "text" );
|
||||||
}
|
}
|
||||||
@ -147,13 +147,13 @@ public SQLServerDialect(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TimeZoneSupport getTimeZoneSupport() {
|
public TimeZoneSupport getTimeZoneSupport() {
|
||||||
return getVersion() >= 10 ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
return getVersion().isSince( 10 ) ? TimeZoneSupport.NATIVE : TimeZoneSupport.NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -198,13 +198,13 @@ public void initializeFunctionRegistry(QueryEngine queryEngine) {
|
|||||||
CommonFunctionFactory.everyAny_sumIif( queryEngine );
|
CommonFunctionFactory.everyAny_sumIif( queryEngine );
|
||||||
CommonFunctionFactory.bitLength_pattern( queryEngine, "datalength(?1) * 8" );
|
CommonFunctionFactory.bitLength_pattern( queryEngine, "datalength(?1) * 8" );
|
||||||
|
|
||||||
if ( getVersion() >= 10 ) {
|
if ( getVersion().isSince( 10 ) ) {
|
||||||
CommonFunctionFactory.locate_charindex( queryEngine );
|
CommonFunctionFactory.locate_charindex( queryEngine );
|
||||||
CommonFunctionFactory.stddevPopSamp_stdevp( queryEngine );
|
CommonFunctionFactory.stddevPopSamp_stdevp( queryEngine );
|
||||||
CommonFunctionFactory.varPopSamp_varp( queryEngine );
|
CommonFunctionFactory.varPopSamp_varp( queryEngine );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( getVersion() >= 11 ) {
|
if ( getVersion().isSince( 11 ) ) {
|
||||||
queryEngine.getSqmFunctionRegistry().register( "format", new SQLServerFormatEmulation( this, queryEngine.getTypeConfiguration() ) );
|
queryEngine.getSqmFunctionRegistry().register( "format", new SQLServerFormatEmulation( this, queryEngine.getTypeConfiguration() ) );
|
||||||
|
|
||||||
//actually translate() was added in 2017 but
|
//actually translate() was added in 2017 but
|
||||||
@ -308,10 +308,10 @@ public String getNoColumnsInsertString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LimitHandler getLimitHandler() {
|
public LimitHandler getLimitHandler() {
|
||||||
if ( getVersion() >= 11 ) {
|
if ( getVersion().isSince( 11 ) ) {
|
||||||
return SQLServer2012LimitHandler.INSTANCE;
|
return SQLServer2012LimitHandler.INSTANCE;
|
||||||
}
|
}
|
||||||
else if ( getVersion() >= 9 ) {
|
else if ( getVersion().isSince( 9 ) ) {
|
||||||
//this is a stateful class, don't cache
|
//this is a stateful class, don't cache
|
||||||
//it in the Dialect!
|
//it in the Dialect!
|
||||||
return new SQLServer2005LimitHandler();
|
return new SQLServer2005LimitHandler();
|
||||||
@ -323,7 +323,7 @@ else if ( getVersion() >= 9 ) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsValuesList() {
|
public boolean supportsValuesList() {
|
||||||
return getVersion() >= 10;
|
return getVersion().isSince( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -338,7 +338,7 @@ public String getCurrentSchemaCommand() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsBeforeTableName() {
|
public boolean supportsIfExistsBeforeTableName() {
|
||||||
if ( getVersion() >= 16 ) {
|
if ( getVersion().isSince( 16 ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.supportsIfExistsBeforeTableName();
|
return super.supportsIfExistsBeforeTableName();
|
||||||
@ -346,7 +346,7 @@ public boolean supportsIfExistsBeforeTableName() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsIfExistsBeforeConstraintName() {
|
public boolean supportsIfExistsBeforeConstraintName() {
|
||||||
if ( getVersion() >= 16 ) {
|
if ( getVersion().isSince( 16 ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return super.supportsIfExistsBeforeConstraintName();
|
return super.supportsIfExistsBeforeConstraintName();
|
||||||
@ -359,7 +359,7 @@ public char openQuote() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String appendLockHint(LockOptions lockOptions, String tableName) {
|
public String appendLockHint(LockOptions lockOptions, String tableName) {
|
||||||
if ( getVersion() >= 9 ) {
|
if ( getVersion().isSince( 9 ) ) {
|
||||||
LockMode lockMode = lockOptions.getAliasSpecificLockMode( tableName );
|
LockMode lockMode = lockOptions.getAliasSpecificLockMode( tableName );
|
||||||
if (lockMode == null) {
|
if (lockMode == null) {
|
||||||
lockMode = lockOptions.getLockMode();
|
lockMode = lockOptions.getLockMode();
|
||||||
@ -462,17 +462,17 @@ public IdentityColumnSupport getIdentityColumnSupport() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNonQueryWithCTE() {
|
public boolean supportsNonQueryWithCTE() {
|
||||||
return getVersion() >= 9;
|
return getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsSkipLocked() {
|
public boolean supportsSkipLocked() {
|
||||||
return getVersion() >= 9;
|
return getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNoWait() {
|
public boolean supportsNoWait() {
|
||||||
return getVersion() >= 9;
|
return getVersion().isSince( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -482,10 +482,10 @@ public boolean supportsWait() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SequenceSupport getSequenceSupport() {
|
public SequenceSupport getSequenceSupport() {
|
||||||
if ( getVersion() < 11 ) {
|
if ( getVersion().isBefore( 11 ) ) {
|
||||||
return NoSequenceSupport.INSTANCE;
|
return NoSequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
else if ( getVersion() >= 16 ) {
|
else if ( getVersion().isSince( 16 ) ) {
|
||||||
return SQLServer16SequenceSupport.INSTANCE;
|
return SQLServer16SequenceSupport.INSTANCE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -495,7 +495,7 @@ else if ( getVersion() >= 16 ) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQuerySequencesString() {
|
public String getQuerySequencesString() {
|
||||||
return getVersion() < 11
|
return getVersion().isBefore( 11 )
|
||||||
? super.getQuerySequencesString() //null
|
? super.getQuerySequencesString() //null
|
||||||
// The upper-case name should work on both case-sensitive
|
// The upper-case name should work on both case-sensitive
|
||||||
// and case-insensitive collations.
|
// and case-insensitive collations.
|
||||||
@ -504,7 +504,7 @@ public String getQuerySequencesString() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getQueryHintString(String sql, String hints) {
|
public String getQueryHintString(String sql, String hints) {
|
||||||
if ( getVersion() < 11 ) {
|
if ( getVersion().isBefore( 11 ) ) {
|
||||||
return super.getQueryHintString( sql, hints );
|
return super.getQueryHintString( sql, hints );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +529,7 @@ public String getQueryHintString(String sql, String hints) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsNullPrecedence() {
|
public boolean supportsNullPrecedence() {
|
||||||
return getVersion() < 10;
|
return getVersion().isBefore( 10 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -544,12 +544,12 @@ public boolean supportsWindowFunctions() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsFetchClause(FetchClauseType type) {
|
public boolean supportsFetchClause(FetchClauseType type) {
|
||||||
return getVersion() >= 11;
|
return getVersion().isSince( 11 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
||||||
if ( getVersion() < 9 ) {
|
if ( getVersion().isBefore( 9 ) ) {
|
||||||
return super.buildSQLExceptionConversionDelegate(); //null
|
return super.buildSQLExceptionConversionDelegate(); //null
|
||||||
}
|
}
|
||||||
return (sqlException, message, sql) -> {
|
return (sqlException, message, sql) -> {
|
||||||
@ -611,7 +611,7 @@ public String extractPattern(TemporalUnit unit) {
|
|||||||
return "(datepart(second,?2)+datepart(nanosecond,?2)/1e9)";
|
return "(datepart(second,?2)+datepart(nanosecond,?2)/1e9)";
|
||||||
case WEEK:
|
case WEEK:
|
||||||
// Thanks https://www.sqlservercentral.com/articles/a-simple-formula-to-calculate-the-iso-week-number
|
// Thanks https://www.sqlservercentral.com/articles/a-simple-formula-to-calculate-the-iso-week-number
|
||||||
if ( getVersion() < 10 ) {
|
if ( getVersion().isBefore( 10 ) ) {
|
||||||
return "(DATEPART(dy,DATEADD(dd,DATEDIFF(dd,'17530101',?2)/7*7,'17530104'))+6)/7)";
|
return "(DATEPART(dy,DATEADD(dd,DATEDIFF(dd,'17530101',?2)/7*7,'17530104'))+6)/7)";
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -641,27 +641,26 @@ public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
public String timestampdiffPattern(TemporalUnit unit, TemporalType fromTemporalType, TemporalType toTemporalType) {
|
||||||
switch (unit) {
|
if ( unit == TemporalUnit.NATIVE ) {//use microsecond as the "native" precision
|
||||||
case NATIVE:
|
return "datediff_big(microsecond,?2,?3)";
|
||||||
//use microsecond as the "native" precision
|
|
||||||
return "datediff_big(microsecond,?2,?3)";
|
|
||||||
default:
|
|
||||||
//datediff() returns an int, and can easily
|
|
||||||
//overflow when dealing with "physical"
|
|
||||||
//durations, so use datediff_big()
|
|
||||||
return unit.normalized() == NANOSECOND
|
|
||||||
? "datediff_big(?1,?2,?3)"
|
|
||||||
: "datediff(?1,?2,?3)";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//datediff() returns an int, and can easily
|
||||||
|
//overflow when dealing with "physical"
|
||||||
|
//durations, so use datediff_big()
|
||||||
|
return unit.normalized() == NANOSECOND
|
||||||
|
? "datediff_big(?1,?2,?3)"
|
||||||
|
: "datediff(?1,?2,?3)";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String translateDurationField(TemporalUnit unit) {
|
public String translateDurationField(TemporalUnit unit) {
|
||||||
switch (unit) {
|
//use microsecond as the "native" precision
|
||||||
//use microsecond as the "native" precision
|
if ( unit == TemporalUnit.NATIVE ) {
|
||||||
case NATIVE: return "microsecond";
|
return "microsecond";
|
||||||
default: return super.translateDurationField(unit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return super.translateDurationField( unit );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -827,7 +826,7 @@ public String getCreateTemporaryTableColumnAnnotation(int sqlTypeCode) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getDropSchemaCommand(String schemaName) {
|
public String[] getDropSchemaCommand(String schemaName) {
|
||||||
if ( getVersion() >= 16 ) {
|
if ( getVersion().isSince( 16 ) ) {
|
||||||
return new String[] { "drop schema if exists " + schemaName };
|
return new String[] { "drop schema if exists " + schemaName };
|
||||||
}
|
}
|
||||||
return super.getDropSchemaCommand( schemaName );
|
return super.getDropSchemaCommand( schemaName );
|
||||||
|
@ -80,7 +80,7 @@ protected boolean renderTableReference(TableReference tableReference, LockMode l
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderLockHint(LockMode lockMode) {
|
private void renderLockHint(LockMode lockMode) {
|
||||||
if ( getDialect().getVersion() >= 9 ) {
|
if ( getDialect().getVersion().isSince( 9 ) ) {
|
||||||
final int effectiveLockTimeout = getEffectiveLockTimeout( lockMode );
|
final int effectiveLockTimeout = getEffectiveLockTimeout( lockMode );
|
||||||
switch ( lockMode ) {
|
switch ( lockMode ) {
|
||||||
//noinspection deprecation
|
//noinspection deprecation
|
||||||
@ -150,7 +150,7 @@ protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpd
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected OffsetFetchClauseMode getOffsetFetchClauseMode(QueryPart queryPart) {
|
protected OffsetFetchClauseMode getOffsetFetchClauseMode(QueryPart queryPart) {
|
||||||
final int version = getDialect().getVersion();
|
final DatabaseVersion version = getDialect().getVersion();
|
||||||
final boolean hasLimit;
|
final boolean hasLimit;
|
||||||
final boolean hasOffset;
|
final boolean hasOffset;
|
||||||
if ( queryPart.isRoot() && hasLimit() ) {
|
if ( queryPart.isRoot() && hasLimit() ) {
|
||||||
@ -164,7 +164,7 @@ protected OffsetFetchClauseMode getOffsetFetchClauseMode(QueryPart queryPart) {
|
|||||||
if ( queryPart instanceof QueryGroup ) {
|
if ( queryPart instanceof QueryGroup ) {
|
||||||
// We can't use TOP for set operations
|
// We can't use TOP for set operations
|
||||||
if ( hasOffset || hasLimit ) {
|
if ( hasOffset || hasLimit ) {
|
||||||
if ( version < 11 || !isRowsOnlyFetchClauseType( queryPart ) ) {
|
if ( version.isBefore( 11 ) || !isRowsOnlyFetchClauseType( queryPart ) ) {
|
||||||
return OffsetFetchClauseMode.EMULATED;
|
return OffsetFetchClauseMode.EMULATED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -175,10 +175,10 @@ protected OffsetFetchClauseMode getOffsetFetchClauseMode(QueryPart queryPart) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( version < 9 || !hasOffset ) {
|
if ( version.isBefore( 9 ) || !hasOffset ) {
|
||||||
return hasLimit ? OffsetFetchClauseMode.TOP_ONLY : null;
|
return hasLimit ? OffsetFetchClauseMode.TOP_ONLY : null;
|
||||||
}
|
}
|
||||||
else if ( version < 11 || !isRowsOnlyFetchClauseType( queryPart ) ) {
|
else if ( version.isBefore( 11 ) || !isRowsOnlyFetchClauseType( queryPart ) ) {
|
||||||
return OffsetFetchClauseMode.EMULATED;
|
return OffsetFetchClauseMode.EMULATED;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -222,7 +222,7 @@ public void visitQuerySpec(QuerySpec querySpec) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needsRowsToSkip() {
|
protected boolean needsRowsToSkip() {
|
||||||
return getDialect().getVersion() < 9;
|
return getDialect().getVersion().isBefore( 9 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -267,7 +267,7 @@ protected void renderEmptyOrderBy() {
|
|||||||
@Override
|
@Override
|
||||||
public void visitOffsetFetchClause(QueryPart queryPart) {
|
public void visitOffsetFetchClause(QueryPart queryPart) {
|
||||||
if ( !isRowNumberingCurrentQueryPart() ) {
|
if ( !isRowNumberingCurrentQueryPart() ) {
|
||||||
if ( getDialect().getVersion() < 9 && !queryPart.isRoot() && queryPart.getOffsetClauseExpression() != null ) {
|
if ( getDialect().getVersion().isBefore( 9 ) && !queryPart.isRoot() && queryPart.getOffsetClauseExpression() != null ) {
|
||||||
throw new IllegalArgumentException( "Can't emulate offset clause in subquery" );
|
throw new IllegalArgumentException( "Can't emulate offset clause in subquery" );
|
||||||
}
|
}
|
||||||
// Note that SQL Server is very strict i.e. it requires an order by clause for TOP or OFFSET
|
// Note that SQL Server is very strict i.e. it requires an order by clause for TOP or OFFSET
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple version of DatabaseVersion
|
||||||
|
*/
|
||||||
|
public class SimpleDatabaseVersion implements DatabaseVersion {
|
||||||
|
public static final SimpleDatabaseVersion ZERO_VERSION = new SimpleDatabaseVersion( 0, 0 );
|
||||||
|
|
||||||
|
private final int major;
|
||||||
|
private final int minor;
|
||||||
|
private final int micro;
|
||||||
|
|
||||||
|
public SimpleDatabaseVersion(DatabaseVersion copySource) {
|
||||||
|
this( copySource, true );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleDatabaseVersion(DatabaseVersion version, boolean noVersionAsZero) {
|
||||||
|
this.major = version.getDatabaseMajorVersion();
|
||||||
|
|
||||||
|
if ( version.getDatabaseMinorVersion() == NO_VERSION ) {
|
||||||
|
this.minor = noVersionAsZero ? 0 : NO_VERSION;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.minor = version.getDatabaseMinorVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( version.getDatabaseMicroVersion() == NO_VERSION ) {
|
||||||
|
this.micro = noVersionAsZero ? 0 : NO_VERSION;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.micro = version.getDatabaseMicroVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleDatabaseVersion(int major, int minor) {
|
||||||
|
this( major, minor, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleDatabaseVersion(int major, int minor, int micro) {
|
||||||
|
this.major = major;
|
||||||
|
this.minor = minor;
|
||||||
|
this.micro = micro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleDatabaseVersion(Integer major, Integer minor) {
|
||||||
|
if ( major == null ) {
|
||||||
|
throw new IllegalArgumentException( "Major version can not be null" );
|
||||||
|
}
|
||||||
|
|
||||||
|
this.major = major;
|
||||||
|
this.minor = minor == null ? NO_VERSION : minor;
|
||||||
|
this.micro = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDatabaseMajorVersion() {
|
||||||
|
return major;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDatabaseMinorVersion() {
|
||||||
|
return minor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDatabaseMicroVersion() {
|
||||||
|
return micro;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMajor() {
|
||||||
|
return major;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinor() {
|
||||||
|
return minor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMicro() {
|
||||||
|
return micro;
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect;
|
package org.hibernate.dialect;
|
||||||
|
|
||||||
|
import java.sql.Types;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.StaleObjectStateException;
|
import org.hibernate.StaleObjectStateException;
|
||||||
@ -46,11 +50,10 @@
|
|||||||
import org.hibernate.type.BasicTypeRegistry;
|
import org.hibernate.type.BasicTypeRegistry;
|
||||||
import org.hibernate.type.StandardBasicTypes;
|
import org.hibernate.type.StandardBasicTypes;
|
||||||
|
|
||||||
import java.sql.Types;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.Map;
|
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hibernate Dialect implementation for Cloud Spanner.
|
* Hibernate Dialect implementation for Cloud Spanner.
|
||||||
*
|
*
|
||||||
@ -112,8 +115,8 @@ public SpannerDialect(DialectResolutionInfo info) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,6 +16,6 @@
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public class Sybase11Dialect extends SybaseASEDialect {
|
public class Sybase11Dialect extends SybaseASEDialect {
|
||||||
public Sybase11Dialect() {
|
public Sybase11Dialect() {
|
||||||
super( 1100, false, false );
|
super( DatabaseVersion.make( 11 ), false, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class SybaseASE157Dialect extends SybaseASEDialect {
|
public class SybaseASE157Dialect extends SybaseASEDialect {
|
||||||
|
|
||||||
public SybaseASE157Dialect() {
|
public SybaseASE157Dialect() {
|
||||||
super( 1570, false, false );
|
super( DatabaseVersion.make( 15, 7 ), false, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
public class SybaseASE15Dialect extends SybaseASEDialect {
|
public class SybaseASE15Dialect extends SybaseASEDialect {
|
||||||
|
|
||||||
public SybaseASE15Dialect() {
|
public SybaseASE15Dialect() {
|
||||||
super( 1500, false, false );
|
super( DatabaseVersion.make( 15 ), false, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import jakarta.persistence.TemporalType;
|
|
||||||
|
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.boot.model.TypeContributions;
|
import org.hibernate.boot.model.TypeContributions;
|
||||||
import org.hibernate.dialect.pagination.LimitHandler;
|
import org.hibernate.dialect.pagination.LimitHandler;
|
||||||
@ -42,6 +40,8 @@
|
|||||||
import org.hibernate.type.descriptor.jdbc.TinyIntJdbcType;
|
import org.hibernate.type.descriptor.jdbc.TinyIntJdbcType;
|
||||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||||
|
|
||||||
|
import jakarta.persistence.TemporalType;
|
||||||
|
|
||||||
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
import static org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor.extractUsingTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,19 +54,19 @@ public class SybaseASEDialect extends SybaseDialect {
|
|||||||
private final boolean ansiNull;
|
private final boolean ansiNull;
|
||||||
|
|
||||||
public SybaseASEDialect() {
|
public SybaseASEDialect() {
|
||||||
this( 1100, false, false );
|
this( DatabaseVersion.make( 11 ), false, false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SybaseASEDialect(DialectResolutionInfo info) {
|
public SybaseASEDialect(DialectResolutionInfo info) {
|
||||||
this(
|
this(
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
info.makeCopy(),
|
||||||
info.getDriverName() != null && info.getDriverName().contains( "jTDS" ),
|
info.getDriverName() != null && info.getDriverName().contains( "jTDS" ),
|
||||||
isAnsiNull( info.unwrap( DatabaseMetaData.class ) )
|
isAnsiNull( info.unwrap( DatabaseMetaData.class ) )
|
||||||
);
|
);
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SybaseASEDialect(int version, boolean jtdsDriver, boolean ansiNull) {
|
public SybaseASEDialect(DatabaseVersion version, boolean jtdsDriver, boolean ansiNull) {
|
||||||
super( version, jtdsDriver );
|
super( version, jtdsDriver );
|
||||||
this.ansiNull = ansiNull;
|
this.ansiNull = ansiNull;
|
||||||
//On Sybase ASE, the 'bit' type cannot be null,
|
//On Sybase ASE, the 'bit' type cannot be null,
|
||||||
@ -76,15 +76,15 @@ public SybaseASEDialect(int version, boolean jtdsDriver, boolean ansiNull) {
|
|||||||
registerColumnType( Types.BOOLEAN, "tinyint" );
|
registerColumnType( Types.BOOLEAN, "tinyint" );
|
||||||
|
|
||||||
|
|
||||||
if ( getVersion() >= 1200 ) {
|
if ( getVersion().isSince( 12 ) ) {
|
||||||
//date / date were introduced in version 12
|
//date / date were introduced in version 12
|
||||||
registerColumnType( Types.DATE, "date" );
|
registerColumnType( Types.DATE, "date" );
|
||||||
registerColumnType( Types.TIME, "time" );
|
registerColumnType( Types.TIME, "time" );
|
||||||
if ( getVersion() >= 1500 ) {
|
if ( getVersion().isSince( 15 ) ) {
|
||||||
//bigint was added in version 15
|
//bigint was added in version 15
|
||||||
registerColumnType( Types.BIGINT, "bigint" );
|
registerColumnType( Types.BIGINT, "bigint" );
|
||||||
|
|
||||||
if ( getVersion() >= 1550 && !jtdsDriver ) {
|
if ( getVersion().isSince( 15, 5 ) && !jtdsDriver ) {
|
||||||
//According to Wikipedia bigdatetime and bigtime were added in 15.5
|
//According to Wikipedia bigdatetime and bigtime were added in 15.5
|
||||||
//But with jTDS we can't use them as the driver can't handle the types
|
//But with jTDS we can't use them as the driver can't handle the types
|
||||||
registerColumnType( Types.DATE, "bigdatetime" );
|
registerColumnType( Types.DATE, "bigdatetime" );
|
||||||
@ -238,7 +238,7 @@ public String timestampaddPattern(TemporalUnit unit, TemporalType temporalType,
|
|||||||
case NATIVE:
|
case NATIVE:
|
||||||
// If the driver or database do not support bigdatetime and bigtime types,
|
// If the driver or database do not support bigdatetime and bigtime types,
|
||||||
// we try to operate on milliseconds instead
|
// we try to operate on milliseconds instead
|
||||||
if ( getVersion() < 1550 || jtdsDriver ) {
|
if ( getVersion().isBefore( 15, 5 ) || jtdsDriver ) {
|
||||||
return "dateadd(millisecond,?2/1000000,?3)";
|
return "dateadd(millisecond,?2/1000000,?3)";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -529,13 +529,13 @@ public boolean supportsPartitionBy() {
|
|||||||
public String getTableTypeString() {
|
public String getTableTypeString() {
|
||||||
//HHH-7298 I don't know if this would break something or cause some side affects
|
//HHH-7298 I don't know if this would break something or cause some side affects
|
||||||
//but it is required to use 'select for update'
|
//but it is required to use 'select for update'
|
||||||
return getVersion() < 1570 ? super.getTableTypeString() : " lock datarows";
|
return getVersion().isBefore( 15, 7 ) ? super.getTableTypeString() : " lock datarows";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsExpectedLobUsagePattern() {
|
public boolean supportsExpectedLobUsagePattern() {
|
||||||
// Earlier Sybase did not support LOB locators at all
|
// Earlier Sybase did not support LOB locators at all
|
||||||
return getVersion() >= 1570;
|
return getVersion().isSince( 15, 7 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -545,17 +545,17 @@ public boolean supportsLobValueChangePropagation() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RowLockStrategy getWriteRowLockStrategy() {
|
public RowLockStrategy getWriteRowLockStrategy() {
|
||||||
return getVersion() >= 1570 ? RowLockStrategy.COLUMN : RowLockStrategy.TABLE;
|
return getVersion().isSince( 15, 7 ) ? RowLockStrategy.COLUMN : RowLockStrategy.TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getForUpdateString() {
|
public String getForUpdateString() {
|
||||||
return getVersion() < 1570 ? "" : " for update";
|
return getVersion().isBefore( 15, 7 ) ? "" : " for update";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getForUpdateString(String aliases) {
|
public String getForUpdateString(String aliases) {
|
||||||
return getVersion() < 1570
|
return getVersion().isBefore( 15, 7 )
|
||||||
? ""
|
? ""
|
||||||
: getForUpdateString() + " of " + aliases;
|
: getForUpdateString() + " of " + aliases;
|
||||||
}
|
}
|
||||||
@ -563,14 +563,14 @@ public String getForUpdateString(String aliases) {
|
|||||||
@Override
|
@Override
|
||||||
public String appendLockHint(LockOptions mode, String tableName) {
|
public String appendLockHint(LockOptions mode, String tableName) {
|
||||||
//TODO: is this really necessary??!
|
//TODO: is this really necessary??!
|
||||||
return getVersion() < 1570 ? super.appendLockHint( mode, tableName ) : tableName;
|
return getVersion().isBefore( 15, 7 ) ? super.appendLockHint( mode, tableName ) : tableName;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
|
public String applyLocksToSql(String sql, LockOptions aliasedLockOptions, Map<String, String[]> keyColumnNames) {
|
||||||
//TODO: is this really correct?
|
//TODO: is this really correct?
|
||||||
return getVersion() < 1570
|
return getVersion().isBefore( 15, 7 )
|
||||||
? super.applyLocksToSql( sql, aliasedLockOptions, keyColumnNames )
|
? super.applyLocksToSql( sql, aliasedLockOptions, keyColumnNames )
|
||||||
: sql + new ForUpdateFragment( this, aliasedLockOptions, keyColumnNames ).toFragmentString();
|
: sql + new ForUpdateFragment( this, aliasedLockOptions, keyColumnNames ).toFragmentString();
|
||||||
}
|
}
|
||||||
@ -618,7 +618,7 @@ public ViolatedConstraintNameExtractor getViolatedConstraintNameExtractor() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
||||||
if ( getVersion() < 1570 ) {
|
if ( getVersion().isBefore( 15, 7 ) ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -660,7 +660,7 @@ public SQLExceptionConversionDelegate buildSQLExceptionConversionDelegate() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LimitHandler getLimitHandler() {
|
public LimitHandler getLimitHandler() {
|
||||||
if ( getVersion() < 1250 ) {
|
if ( getVersion().isBefore( 12, 5 ) ) {
|
||||||
//support for SELECT TOP was introduced in Sybase ASE 12.5.3
|
//support for SELECT TOP was introduced in Sybase ASE 12.5.3
|
||||||
return super.getLimitHandler();
|
return super.getLimitHandler();
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
|
||||||
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
import org.hibernate.sql.ast.spi.AbstractSqlAstTranslator;
|
||||||
import org.hibernate.sql.ast.spi.SqlSelection;
|
import org.hibernate.sql.ast.spi.SqlSelection;
|
||||||
import org.hibernate.sql.ast.tree.MutationStatement;
|
|
||||||
import org.hibernate.sql.ast.tree.Statement;
|
import org.hibernate.sql.ast.tree.Statement;
|
||||||
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
import org.hibernate.sql.ast.tree.cte.CteStatement;
|
||||||
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
|
import org.hibernate.sql.ast.tree.expression.CaseSearchedExpression;
|
||||||
@ -101,7 +100,7 @@ protected void visitAnsiCaseSimpleExpression(
|
|||||||
@Override
|
@Override
|
||||||
protected boolean renderTableReference(TableReference tableReference, LockMode lockMode) {
|
protected boolean renderTableReference(TableReference tableReference, LockMode lockMode) {
|
||||||
super.renderTableReference( tableReference, lockMode );
|
super.renderTableReference( tableReference, lockMode );
|
||||||
if ( getDialect().getVersion() < 1570 ) {
|
if ( getDialect().getVersion().isBefore( 15, 7 ) ) {
|
||||||
if ( LockMode.READ.lessThan( lockMode ) ) {
|
if ( LockMode.READ.lessThan( lockMode ) ) {
|
||||||
appendSql( " holdlock" );
|
appendSql( " holdlock" );
|
||||||
}
|
}
|
||||||
@ -122,7 +121,7 @@ protected void renderJoinType(SqlAstJoinType joinType) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
protected void renderForUpdateClause(QuerySpec querySpec, ForUpdateClause forUpdateClause) {
|
||||||
if ( getDialect().getVersion() < 1570 ) {
|
if ( getDialect().getVersion().isBefore( 15, 7 ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
super.renderForUpdateClause( querySpec, forUpdateClause );
|
super.renderForUpdateClause( querySpec, forUpdateClause );
|
||||||
@ -209,7 +208,7 @@ protected void renderOffsetExpression(Expression offsetExpression) {
|
|||||||
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
|
protected void renderComparison(Expression lhs, ComparisonOperator operator, Expression rhs) {
|
||||||
// I think intersect is only supported in 16.0 SP3
|
// I think intersect is only supported in 16.0 SP3
|
||||||
if ( getDialect().isAnsiNullOn() ) {
|
if ( getDialect().isAnsiNullOn() ) {
|
||||||
if ( getDialect().getVersion() >= 1630 ) {
|
if ( getDialect().getVersion().isSince( 16, 3 ) ) {
|
||||||
renderComparisonEmulateIntersect( lhs, operator, rhs );
|
renderComparisonEmulateIntersect( lhs, operator, rhs );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -258,7 +257,7 @@ protected void renderComparison(Expression lhs, ComparisonOperator operator, Exp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ( getDialect().getVersion() >= 1630 ) {
|
if ( getDialect().getVersion().isSince( 16, 3 ) ) {
|
||||||
renderComparisonEmulateIntersect( lhs, operator, rhs );
|
renderComparisonEmulateIntersect( lhs, operator, rhs );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -363,7 +362,7 @@ protected String getFromDual() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsTopClause() {
|
private boolean supportsTopClause() {
|
||||||
return getDialect().getVersion() >= 1250;
|
return getDialect().getVersion().isSince( 12, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean supportsParameterOffsetFetchExpression() {
|
private boolean supportsParameterOffsetFetchExpression() {
|
||||||
|
@ -59,25 +59,25 @@
|
|||||||
*/
|
*/
|
||||||
public class SybaseDialect extends AbstractTransactSQLDialect {
|
public class SybaseDialect extends AbstractTransactSQLDialect {
|
||||||
|
|
||||||
private final int version;
|
private final DatabaseVersion version;
|
||||||
protected final boolean jtdsDriver;
|
protected final boolean jtdsDriver;
|
||||||
|
|
||||||
//All Sybase dialects share an IN list size limit.
|
//All Sybase dialects share an IN list size limit.
|
||||||
private static final int PARAM_LIST_SIZE_LIMIT = 250000;
|
private static final int PARAM_LIST_SIZE_LIMIT = 250000;
|
||||||
|
|
||||||
public SybaseDialect(){
|
public SybaseDialect(){
|
||||||
this( 1100, false );
|
this( DatabaseVersion.make( 11, 0 ), false );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SybaseDialect(DialectResolutionInfo info){
|
public SybaseDialect(DialectResolutionInfo info){
|
||||||
this(
|
this(
|
||||||
info.getDatabaseMajorVersion() * 100 + info.getDatabaseMinorVersion() * 10,
|
info.makeCopy(),
|
||||||
info.getDriverName() != null && info.getDriverName().contains( "jTDS" )
|
info.getDriverName() != null && info.getDriverName().contains( "jTDS" )
|
||||||
);
|
);
|
||||||
registerKeywords( info );
|
registerKeywords( info );
|
||||||
}
|
}
|
||||||
|
|
||||||
public SybaseDialect(int version, boolean jtdsDriver) {
|
public SybaseDialect(DatabaseVersion version, boolean jtdsDriver) {
|
||||||
super();
|
super();
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.jtdsDriver = jtdsDriver;
|
this.jtdsDriver = jtdsDriver;
|
||||||
@ -147,7 +147,7 @@ protected <T extends JdbcOperation> SqlAstTranslator<T> buildTranslator(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, D
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameQualifierSupport getNameQualifierSupport() {
|
public NameQualifierSupport getNameQualifierSupport() {
|
||||||
if ( version >= 1500 ) {
|
if ( version.isSince( 15 ) ) {
|
||||||
return NameQualifierSupport.BOTH;
|
return NameQualifierSupport.BOTH;
|
||||||
}
|
}
|
||||||
return NameQualifierSupport.CATALOG;
|
return NameQualifierSupport.CATALOG;
|
||||||
|
@ -46,7 +46,7 @@ public TiDBDialect(DialectResolutionInfo info) {
|
|||||||
|
|
||||||
public TiDBDialect(int version, int characterSetBytesPerCharacter) {
|
public TiDBDialect(int version, int characterSetBytesPerCharacter) {
|
||||||
// For simplicity’s sake, configure MySQL 5.7 compatibility
|
// For simplicity’s sake, configure MySQL 5.7 compatibility
|
||||||
super( 570, characterSetBytesPerCharacter );
|
super( DatabaseVersion.make( 5, 7 ), characterSetBytesPerCharacter );
|
||||||
this.tidbVersion = version;
|
this.tidbVersion = version;
|
||||||
registerKeywords();
|
registerKeywords();
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public boolean supportsRowValueConstructorSyntaxInSet() {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsRowValueConstructorSyntaxInInList() {
|
public boolean supportsRowValueConstructorSyntaxInInList() {
|
||||||
return getDialect().getVersion() >= 570;
|
return getDialect().getVersion().isSince( 5, 7 );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect.identity;
|
package org.hibernate.dialect.identity;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
*/
|
*/
|
||||||
public class HSQLIdentityColumnSupport extends IdentityColumnSupportImpl {
|
public class HSQLIdentityColumnSupport extends IdentityColumnSupportImpl {
|
||||||
|
final private DatabaseVersion dbVersion;
|
||||||
|
|
||||||
final private int hsqldbVersion;
|
public HSQLIdentityColumnSupport(DatabaseVersion dbVersion) {
|
||||||
|
this.dbVersion = dbVersion;
|
||||||
public HSQLIdentityColumnSupport(int hsqldbVersion) {
|
|
||||||
|
|
||||||
this.hsqldbVersion = hsqldbVersion;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,6 +36,6 @@ public String getIdentitySelectString(String table, String column, int type) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentityInsertString() {
|
public String getIdentityInsertString() {
|
||||||
return hsqldbVersion < 200 ? "null" : "default";
|
return dbVersion.isBefore( 2 ) ? "null" : "default";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.dialect.pagination;
|
package org.hibernate.dialect.pagination;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.query.Limit;
|
import org.hibernate.query.Limit;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@ -14,10 +15,9 @@
|
|||||||
* A {@link LimitHandler} for Oracle prior to 12c, which uses {@code ROWNUM}.
|
* A {@link LimitHandler} for Oracle prior to 12c, which uses {@code ROWNUM}.
|
||||||
*/
|
*/
|
||||||
public class LegacyOracleLimitHandler extends AbstractLimitHandler {
|
public class LegacyOracleLimitHandler extends AbstractLimitHandler {
|
||||||
|
private final DatabaseVersion version;
|
||||||
|
|
||||||
private final int version;
|
public LegacyOracleLimitHandler(DatabaseVersion version) {
|
||||||
|
|
||||||
public LegacyOracleLimitHandler(int version) {
|
|
||||||
this.version = version;
|
this.version = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ public String processSql(String sql, Limit limit) {
|
|||||||
final StringBuilder pagingSelect = new StringBuilder( sql.length() + 100 );
|
final StringBuilder pagingSelect = new StringBuilder( sql.length() + 100 );
|
||||||
if ( hasOffset ) {
|
if ( hasOffset ) {
|
||||||
pagingSelect.append( "select * from (select row_.*,rownum rownum_ from (" ).append( sql );
|
pagingSelect.append( "select * from (select row_.*,rownum rownum_ from (" ).append( sql );
|
||||||
if ( version < 900 ) {
|
if ( version.isBefore( 9 ) ) {
|
||||||
pagingSelect.append( ") row_) where rownum_<=? and rownum_>?" );
|
pagingSelect.append( ") row_) where rownum_<=? and rownum_>?" );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -376,7 +376,7 @@ public void testNonGetter(SessionFactoryScope scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(dialectClass = OracleDialect.class, version = 1000, reason = "oracle12c returns time in getDate. For now, skip.")
|
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 10, reason = "oracle12c returns time in getDate. For now, skip.")
|
||||||
public void testTemporalType(SessionFactoryScope scope) {
|
public void testTemporalType(SessionFactoryScope scope) {
|
||||||
final ZoneId zoneId = ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof MySQLDialect ) ? ZoneId.of( "UTC")
|
final ZoneId zoneId = ( scope.getSessionFactory().getJdbcServices().getDialect() instanceof MySQLDialect ) ? ZoneId.of( "UTC")
|
||||||
: ZoneId.systemDefault();
|
: ZoneId.systemDefault();
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-11236")
|
@TestForIssue(jiraKey = "HHH-11236")
|
||||||
@RequiresDialect(value = MySQLDialect.class, version = 500)
|
@RequiresDialect(value = MySQLDialect.class, majorVersion = 5)
|
||||||
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsJdbcDriverProxying.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsJdbcDriverProxying.class)
|
||||||
@BaseUnitTest
|
@BaseUnitTest
|
||||||
public class MySQLDropConstraintThrowsExceptionTest {
|
public class MySQLDropConstraintThrowsExceptionTest {
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
import org.hibernate.boot.model.naming.Identifier;
|
import org.hibernate.boot.model.naming.Identifier;
|
||||||
import org.hibernate.boot.model.relational.Namespace;
|
import org.hibernate.boot.model.relational.Namespace;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
import org.hibernate.engine.jdbc.env.spi.NameQualifierSupport;
|
||||||
@ -24,6 +25,7 @@
|
|||||||
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
import org.hibernate.testing.junit4.BaseNonConfigCoreFunctionalTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
|
|
||||||
@ -90,8 +92,8 @@ public NameQualifierSupport getNameQualifierSupport() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,9 @@
|
|||||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||||
import org.hibernate.cache.spi.access.AccessType;
|
import org.hibernate.cache.spi.access.AccessType;
|
||||||
import org.hibernate.cfg.AvailableSettings;
|
import org.hibernate.cfg.AvailableSettings;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
|
import org.hibernate.dialect.SimpleDatabaseVersion;
|
||||||
import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
|
import org.hibernate.engine.jdbc.connections.internal.DatasourceConnectionProviderImpl;
|
||||||
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
import org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl;
|
||||||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||||
@ -523,16 +525,16 @@ public Properties getProperties() {
|
|||||||
|
|
||||||
public static class PersistenceUnitDialect extends Dialect {
|
public static class PersistenceUnitDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public static class IntegrationDialect extends Dialect {
|
public static class IntegrationDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.dialect;
|
package org.hibernate.orm.test.dialect;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.query.Limit;
|
import org.hibernate.query.Limit;
|
||||||
|
|
||||||
@ -29,7 +30,7 @@ public void testInsertLimitClause() {
|
|||||||
final String input = "select * from tablename t where t.cat = 5";
|
final String input = "select * from tablename t where t.cat = 5";
|
||||||
final String expected = "select * from tablename t where t.cat = 5 fetch first " + limit + " rows only";
|
final String expected = "select * from tablename t where t.cat = 5 fetch first " + limit + " rows only";
|
||||||
|
|
||||||
final String actual = new DerbyDialect( 1050 ).getLimitHandler().processSql( input, toRowSelection( 0, limit ) );
|
final String actual = new DerbyDialect( DatabaseVersion.make( 10, 5 ) ).getLimitHandler().processSql( input, toRowSelection( 0, limit ) );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public void testInsertLimitWithOffsetClause() {
|
|||||||
final String input = "select * from tablename t where t.cat = 5";
|
final String input = "select * from tablename t where t.cat = 5";
|
||||||
final String expected = "select * from tablename t where t.cat = 5 offset " + offset + " rows fetch next " + limit + " rows only";
|
final String expected = "select * from tablename t where t.cat = 5 offset " + offset + " rows fetch next " + limit + " rows only";
|
||||||
|
|
||||||
final String actual = new DerbyDialect( 1050 ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
final String actual = new DerbyDialect( DatabaseVersion.make( 10, 5 ) ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ public void testInsertLimitWithForUpdateClause() {
|
|||||||
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 offset " + offset
|
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 offset " + offset
|
||||||
+ " rows fetch next " + limit + " rows only for update of c11, c13";
|
+ " rows fetch next " + limit + " rows only for update of c11, c13";
|
||||||
|
|
||||||
final String actual = new DerbyDialect( 1050 ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
final String actual = new DerbyDialect( DatabaseVersion.make( 10, 5 ) ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public void testInsertLimitWithWithClause() {
|
|||||||
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset " + offset
|
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset " + offset
|
||||||
+ " rows fetch next " + limit + " rows only with rr";
|
+ " rows fetch next " + limit + " rows only with rr";
|
||||||
|
|
||||||
final String actual = new DerbyDialect( 1050 ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
final String actual = new DerbyDialect( DatabaseVersion.make( 10, 5 ) ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ public void testInsertLimitWithForUpdateAndWithClauses() {
|
|||||||
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset " + offset
|
final String expected = "select c11 as col1, c12 as col2, c13 as col13 from t1 where flight_id between 'AA1111' and 'AA1112' offset " + offset
|
||||||
+ " rows fetch next " + limit + " rows only for update of c11,c13 with rr";
|
+ " rows fetch next " + limit + " rows only for update of c11,c13 with rr";
|
||||||
|
|
||||||
final String actual = new DerbyDialect( 1050 ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
final String actual = new DerbyDialect( DatabaseVersion.make( 10, 5 ) ).getLimitHandler().processSql( input, toRowSelection( offset, limit ) );
|
||||||
assertEquals( expected, actual );
|
assertEquals( expected, actual );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,11 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.dialect;
|
package org.hibernate.orm.test.dialect;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.BasicDialectResolver;
|
import org.hibernate.engine.jdbc.dialect.spi.BasicDialectResolver;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolutionInfo;
|
||||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||||
|
|
||||||
|
import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
@ -18,8 +21,8 @@ public class TestingDialects {
|
|||||||
|
|
||||||
public static class MyDialect extends Dialect {
|
public static class MyDialect extends Dialect {
|
||||||
@Override
|
@Override
|
||||||
public int getVersion() {
|
public DatabaseVersion getVersion() {
|
||||||
return 0;
|
return ZERO_VERSION;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
xmlMappings = "org/hibernate/orm/test/dialect/function/Product.hbm.xml"
|
xmlMappings = "org/hibernate/orm/test/dialect/function/Product.hbm.xml"
|
||||||
)
|
)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@RequiresDialect(value = SybaseASEDialect.class, version = 1100)
|
@RequiresDialect(value = SybaseASEDialect.class, majorVersion = 11)
|
||||||
public class SybaseASEFunctionTest {
|
public class SybaseASEFunctionTest {
|
||||||
|
|
||||||
private Calendar calendar = Calendar.getInstance();
|
private Calendar calendar = Calendar.getInstance();
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
)
|
)
|
||||||
@SessionFactory(exportSchema = false)
|
@SessionFactory(exportSchema = false)
|
||||||
@RequiresDialect(HANAColumnStoreDialect.class)
|
@RequiresDialect(HANAColumnStoreDialect.class)
|
||||||
@SkipForDialect(dialectClass = HANAColumnStoreDialect.class, version = 400)
|
@SkipForDialect(dialectClass = HANAColumnStoreDialect.class, majorVersion = 4)
|
||||||
public class HANASearchTest {
|
public class HANASearchTest {
|
||||||
|
|
||||||
private static final String ENTITY_NAME = "SearchEntity";
|
private static final String ENTITY_NAME = "SearchEntity";
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
/**
|
/**
|
||||||
* @author Nathan Xu
|
* @author Nathan Xu
|
||||||
*/
|
*/
|
||||||
@RequiresDialect(value = MariaDBDialect.class, version = 1030)
|
@RequiresDialect(value = MariaDBDialect.class, majorVersion = 10, minorVersion = 3)
|
||||||
public class MariaDBExtractSequenceMetadataTest {
|
public class MariaDBExtractSequenceMetadataTest {
|
||||||
|
|
||||||
private static String primaryDbName;
|
private static String primaryDbName;
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@TestForIssue(jiraKey = "HHH-12973")
|
@TestForIssue(jiraKey = "HHH-12973")
|
||||||
@RequiresDialect(value = MariaDBDialect.class, version = 1030)
|
@RequiresDialect(value = MariaDBDialect.class, majorVersion = 10, minorVersion = 3)
|
||||||
@Jpa(
|
@Jpa(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
SequenceInformationMariaDBTest.Book.class,
|
SequenceInformationMariaDBTest.Book.class,
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
import org.hibernate.LockOptions;
|
import org.hibernate.LockOptions;
|
||||||
import org.hibernate.dialect.DB2Dialect;
|
import org.hibernate.dialect.DB2Dialect;
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -20,7 +21,7 @@
|
|||||||
*/
|
*/
|
||||||
public class DB2LockTimeoutTest extends BaseUnitTestCase {
|
public class DB2LockTimeoutTest extends BaseUnitTestCase {
|
||||||
|
|
||||||
private final Dialect dialect = new DB2Dialect( 1150 );
|
private final Dialect dialect = new DB2Dialect( DatabaseVersion.make( 11, 5 ) );
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLockTimeoutNoAliasNoTimeout() {
|
public void testLockTimeoutNoAliasNoTimeout() {
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.dialect.unit.sequence;
|
package org.hibernate.orm.test.dialect.unit.sequence;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl;
|
||||||
@ -21,7 +22,7 @@ public class DerbyTenFiveDialectSequenceInformationExtractorTest extends Abstrac
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialect getDialect() {
|
public Dialect getDialect() {
|
||||||
return new DerbyDialect( 1050 );
|
return new DerbyDialect( DatabaseVersion.make( 10, 5 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.dialect.unit.sequence;
|
package org.hibernate.orm.test.dialect.unit.sequence;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
||||||
@ -20,7 +21,7 @@
|
|||||||
public class DerbyTenSevenDialectSequenceInformationExtractorTest extends AbstractSequenceInformationExtractorTest {
|
public class DerbyTenSevenDialectSequenceInformationExtractorTest extends AbstractSequenceInformationExtractorTest {
|
||||||
@Override
|
@Override
|
||||||
public Dialect getDialect() {
|
public Dialect getDialect() {
|
||||||
return new DerbyDialect( 1070 );
|
return new DerbyDialect( DatabaseVersion.make( 10, 7 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.dialect.unit.sequence;
|
package org.hibernate.orm.test.dialect.unit.sequence;
|
||||||
|
|
||||||
|
import org.hibernate.dialect.DatabaseVersion;
|
||||||
import org.hibernate.dialect.DerbyDialect;
|
import org.hibernate.dialect.DerbyDialect;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorLegacyImpl;
|
||||||
@ -20,7 +21,7 @@
|
|||||||
public class DerbyTenSixDialectSequenceInformationExtractorTest extends AbstractSequenceInformationExtractorTest {
|
public class DerbyTenSixDialectSequenceInformationExtractorTest extends AbstractSequenceInformationExtractorTest {
|
||||||
@Override
|
@Override
|
||||||
public Dialect getDialect() {
|
public Dialect getDialect() {
|
||||||
return new DerbyDialect( 1060 );
|
return new DerbyDialect( DatabaseVersion.make( 10, 6 ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
xmlMappings = "org/hibernate/orm/test/generatedkeys/select/MyEntity.hbm.xml"
|
xmlMappings = "org/hibernate/orm/test/generatedkeys/select/MyEntity.hbm.xml"
|
||||||
)
|
)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@RequiresDialect(value = OracleDialect.class, version = 900)
|
@RequiresDialect(value = OracleDialect.class, majorVersion = 9)
|
||||||
public class SelectGeneratorTest {
|
public class SelectGeneratorTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
)
|
)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@TestForIssue( jiraKey = "HHH-13365" )
|
@TestForIssue( jiraKey = "HHH-13365" )
|
||||||
@RequiresDialect( value = OracleDialect.class, version = 900 )
|
@RequiresDialect( value = OracleDialect.class, majorVersion = 9 )
|
||||||
public class JoinedSequenceIdentityBatchTest {
|
public class JoinedSequenceIdentityBatchTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
xmlMappings = "org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml"
|
xmlMappings = "org/hibernate/orm/test/generatedkeys/seqidentity/MyEntity.hbm.xml"
|
||||||
)
|
)
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
@RequiresDialect(value = OracleDialect.class, version = 900)
|
@RequiresDialect(value = OracleDialect.class, majorVersion = 9)
|
||||||
public class SequenceIdentityTest {
|
public class SequenceIdentityTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -62,7 +62,7 @@ public void testTupleReturnFails(SessionFactoryScope scope) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SkipForDialect(dialectClass = SybaseASEDialect.class, version = 1500, matchSubTypes = true, reason = "HHH-5229")
|
@SkipForDialect(dialectClass = SybaseASEDialect.class, majorVersion = 15, matchSubTypes = true, reason = "HHH-5229")
|
||||||
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
|
@SkipForDialect(dialectClass = AbstractHANADialect.class, matchSubTypes = true, reason = "HANA only supports forward-only cursors.")
|
||||||
public void testScrollingJoinFetchesEmptyResultSet(SessionFactoryScope scope) {
|
public void testScrollingJoinFetchesEmptyResultSet(SessionFactoryScope scope) {
|
||||||
scope.inTransaction(
|
scope.inTransaction(
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* @author Vlad Mihalcea
|
* @author Vlad Mihalcea
|
||||||
*/
|
*/
|
||||||
@RequiresDialectFeature(feature = SupportsIdentityColumns.class, jiraKey = "HHH-9271")
|
@RequiresDialectFeature(feature = SupportsIdentityColumns.class, jiraKey = "HHH-9271")
|
||||||
@SkipForDialect(dialectClass = OracleDialect.class, version = 1200, matchSubTypes = true, reason = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
|
@SkipForDialect(dialectClass = OracleDialect.class, majorVersion = 12, matchSubTypes = true, reason = "Oracle and identity column: java.sql.Connection#prepareStatement(String sql, int columnIndexes[]) does not work with quoted table names and/or quoted columnIndexes")
|
||||||
@DomainModel(
|
@DomainModel(
|
||||||
annotatedClasses = {
|
annotatedClasses = {
|
||||||
QuotedIdentifierTest.QuotedIdentifier.class
|
QuotedIdentifierTest.QuotedIdentifier.class
|
||||||
|
@ -46,7 +46,7 @@ public void tearDown(SessionFactoryScope scope){
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-8814")
|
@TestForIssue(jiraKey = "HHH-8814")
|
||||||
@RequiresDialect(value = SQLServerDialect.class, version = 2012)
|
@RequiresDialect(value = SQLServerDialect.class, majorVersion = 11)
|
||||||
public void testStartOfSequence(SessionFactoryScope scope) {
|
public void testStartOfSequence(SessionFactoryScope scope) {
|
||||||
final Person person = scope.fromTransaction( session -> {
|
final Person person = scope.fromTransaction( session -> {
|
||||||
final Person _person = new Person();
|
final Person _person = new Person();
|
||||||
|
@ -39,7 +39,7 @@ public void tearDown(SessionFactoryScope scope) {
|
|||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
@TestForIssue(jiraKey = "HHH-8814")
|
@TestForIssue(jiraKey = "HHH-8814")
|
||||||
@RequiresDialect(value = SQLServerDialect.class, version = 2012)
|
@RequiresDialect(value = SQLServerDialect.class, majorVersion = 11)
|
||||||
public void testStartOfSequence(SessionFactoryScope scope) {
|
public void testStartOfSequence(SessionFactoryScope scope) {
|
||||||
final Person person = scope.fromTransaction( session -> {
|
final Person person = scope.fromTransaction( session -> {
|
||||||
final Person _person = new Person();
|
final Person _person = new Person();
|
||||||
|
@ -38,7 +38,7 @@ public class SequenceGeneratorTest {
|
|||||||
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
@RequiresDialectFeature(feature = DialectFeatureChecks.SupportsSequences.class)
|
||||||
@SkipForDialect(
|
@SkipForDialect(
|
||||||
dialectClass = SQLServerDialect.class,
|
dialectClass = SQLServerDialect.class,
|
||||||
version = 2012,
|
majorVersion = 11,
|
||||||
reason = "SQLServer2012Dialect initializes sequence to minimum value (e.g., Long.MIN_VALUE; Hibernate assumes it is uninitialized.",
|
reason = "SQLServer2012Dialect initializes sequence to minimum value (e.g., Long.MIN_VALUE; Hibernate assumes it is uninitialized.",
|
||||||
matchSubTypes = true
|
matchSubTypes = true
|
||||||
)
|
)
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user