From ccc88e9ad46ffb684b94eca9e76127b35b8d049d Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 11 Dec 2021 18:33:52 +0100 Subject: [PATCH] update the community dialects --- .../community/dialect/CUBRIDDialect.java | 22 ++++++++++---- .../community/dialect/FirebirdDialect.java | 29 ++++++++++--------- .../community/dialect/InformixDialect.java | 14 ++++++++- .../community/dialect/IngresDialect.java | 28 +++++++++++++----- .../community/dialect/MaxDBDialect.java | 6 ++++ .../community/dialect/RDMSOS2200Dialect.java | 16 ++++++---- .../community/dialect/SQLiteDialect.java | 6 ++++ .../community/dialect/TeradataDialect.java | 13 ++++++++- .../community/dialect/TimesTenDialect.java | 22 +++++++------- 9 files changed, 111 insertions(+), 45 deletions(-) diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java index 7b942c6de3..69a90d5242 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/CUBRIDDialect.java @@ -67,13 +67,14 @@ public class CUBRIDDialect extends Dialect { //'timestamp' has a very limited range //'datetime' does not support explicit precision //(always 3, millisecond precision) - registerColumnType(Types.TIMESTAMP, "datetime"); - registerColumnType(Types.TIMESTAMP, "datetimetz"); + registerColumnType(Types.TIMESTAMP, "datetime" ); + registerColumnType(Types.TIMESTAMP, "datetimetz" ); //CUBRID has no 'binary' nor 'varbinary', but 'bit' is - //intended to be used for binary data - registerColumnType( Types.BINARY, "bit($l)"); - registerColumnType( Types.VARBINARY, "bit varying($l)"); + //intended to be used for binary data (unfortunately the + //length parameter is measured in bits, not bytes) + registerColumnType( Types.BINARY, "bit($l)" ); + registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "bit varying($l)" ); getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); @@ -115,6 +116,17 @@ public class CUBRIDDialect extends Dialect { registerKeywords( info ); } + @Override + public int getMaxVarcharLength() { + return 1_073_741_823; + } + + @Override + public int getMaxVarbinaryLength() { + //note that the length of BIT VARYING in CUBRID is actually in bits + return 1_073_741_823; + } + @Override public DatabaseVersion getVersion() { return VERSION; diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdDialect.java index b56725c6cc..a906c91a2d 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/FirebirdDialect.java @@ -141,23 +141,12 @@ public class FirebirdDialect extends Dialect { else { registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp with time zone" ); } - // Single byte character sets can be 32_765 characters, but assume use of UTF8 - registerColumnType( Types.VARCHAR, 8_191, "varchar($l)" ); + registerColumnType( Types.VARCHAR, "blob sub_type text" ); if ( getVersion().isBefore( 4, 0 ) ) { - registerColumnType( Types.BINARY, 32_767, "char($l) character set octets" ); - } - else { - registerColumnType( Types.BINARY, 32_767, "binary($l)" ); - } - registerColumnType( Types.BINARY, "blob sub_type binary" ); - - if ( getVersion().isBefore( 4, 0 ) ) { - registerColumnType( Types.VARBINARY, 32_765, "varchar($l) character set octets" ); - } - else { - registerColumnType( Types.VARBINARY, 32_765, "varbinary($l)" ); + registerColumnType( Types.BINARY, "char($l) character set octets" ); + registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "varchar($l) character set octets" ); } registerColumnType( Types.VARBINARY, "blob sub_type binary" ); @@ -168,6 +157,18 @@ public class FirebirdDialect extends Dialect { getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, NO_BATCH ); } + @Override + public int getMaxVarcharLength() { + // Single byte character sets can be 32_765 + // characters, but assume use of UTF8 + return 8_191; + } + + @Override + public int getMaxVarbinaryLength() { + return 32_756; + } + @Override public DatabaseVersion getVersion() { return version; diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java index c85a190f2a..18c3f2a69e 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/InformixDialect.java @@ -107,7 +107,7 @@ public class InformixDialect extends Dialect { registerColumnType( Types.VARBINARY, "byte" ); registerColumnType( Types.VARCHAR, 255, "varchar($l)" ); - registerColumnType( Types.VARCHAR, 32_739, "lvarchar($l)" ); + registerColumnType( Types.VARCHAR, getMaxVarcharLength(), "lvarchar($l)" ); registerColumnType( Types.VARCHAR, "text" ); uniqueDelegate = new InformixUniqueDelegate( this ); @@ -120,6 +120,18 @@ public class InformixDialect extends Dialect { : new SkipFirstLimitHandler( getVersion().isSameOrAfter( 11 ) ); } + @Override + public int getMaxVarbinaryLength() { + //there's no varbinary type, only byte + return -1; + } + + @Override + public int getMaxVarcharLength() { + //the maximum length of an lvarchar + return 32_739; + } + @Override public DatabaseVersion getVersion() { return version; diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/IngresDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/IngresDialect.java index f0eb352712..48d441d202 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/IngresDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/IngresDialect.java @@ -119,10 +119,8 @@ public class IngresDialect extends Dialect { registerColumnType( Types.NUMERIC, "decimal($p, $s)" ); //Ingres has no 'numeric' type - final int maxStringLength = 32_000; - - registerColumnType( Types.BINARY, maxStringLength, "byte($l)" ); - registerColumnType( Types.VARBINARY, maxStringLength, "varbyte($l)" ); + registerColumnType( Types.BINARY, "byte($l)" ); + registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "varbyte($l)" ); //note: 'long byte' is a synonym for 'blob' registerColumnType( Types.VARBINARY, "long byte($l)" ); @@ -130,13 +128,13 @@ public class IngresDialect extends Dialect { // here? I think Ingres char/varchar types don't // support Unicode. Copy what AbstractHANADialect // does with a Hibernate property to config this. - registerColumnType( Types.CHAR, maxStringLength, "char($l)" ); - registerColumnType( Types.VARCHAR, maxStringLength, "varchar($l)" ); + registerColumnType( Types.CHAR, "char($l)" ); + registerColumnType( Types.VARCHAR, getMaxVarcharLength(), "varchar($l)" ); //note: 'long varchar' is a synonym for 'clob' registerColumnType( Types.VARCHAR, "long varchar($l)" ); - registerColumnType( Types.NCHAR, maxStringLength, "nchar($l)" ); - registerColumnType( Types.NVARCHAR, maxStringLength, "nvarchar($l)" ); + registerColumnType( Types.NCHAR, "nchar($l)" ); + registerColumnType( Types.NVARCHAR, getMaxNVarcharLength(), "nvarchar($l)" ); //note: 'long nvarchar' is a synonym for 'nclob' registerColumnType( Types.NVARCHAR, "long nvarchar($l)" ); @@ -180,6 +178,20 @@ public class IngresDialect extends Dialect { return version; } + @Override + public int getMaxVarcharLength() { + // the maximum possible (configurable) value for + // both varchar and varbyte + return 32_000; + } + + @Override + public int getMaxNVarcharLength() { + // the maximum possible (configurable) value for + // nvarchar + return 16_000; + } + @Override public JdbcType resolveSqlTypeDescriptor( String columnTypeName, diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MaxDBDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MaxDBDialect.java index b17313a5da..e45bb33c7d 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MaxDBDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MaxDBDialect.java @@ -68,6 +68,12 @@ public class MaxDBDialect extends Dialect { getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE ); } + @Override + public int getMaxVarbinaryLength() { + // there's no varbinary type + return -1; + } + @Override public JdbcType resolveSqlTypeDescriptor( String columnTypeName, diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/RDMSOS2200Dialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/RDMSOS2200Dialect.java index 891567ef3a..3260371945 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/RDMSOS2200Dialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/RDMSOS2200Dialect.java @@ -106,17 +106,17 @@ public class RDMSOS2200Dialect extends Dialect { registerColumnType( Types.BLOB, "blob($l)" ); //no 'binary' nor 'varbinary' so use 'blob' - registerColumnType( Types.BINARY, "blob($l)"); - registerColumnType( Types.VARBINARY, "blob($l)"); + registerColumnType( Types.BINARY, "blob($l)" ); + registerColumnType( Types.VARBINARY, "blob($l)" ); //'varchar' is not supported in RDMS for OS 2200 //(but it is for other flavors of RDMS) //'character' means ASCII by default, 'unicode(n)' //means 'character(n) character set "UCS-2"' - registerColumnType( Types.CHAR, "unicode($l)"); - registerColumnType( Types.VARCHAR, "unicode($l)"); + registerColumnType( Types.CHAR, "unicode($l)" ); + registerColumnType( Types.VARCHAR, getMaxVarcharLength(), "unicode($l)" ); - registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)"); + registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" ); } public RDMSOS2200Dialect(DialectResolutionInfo info) { @@ -124,6 +124,12 @@ public class RDMSOS2200Dialect extends Dialect { registerKeywords( info ); } + @Override + public int getMaxVarbinaryLength() { + //no varbinary type + return -1; + } + @Override public DatabaseVersion getVersion() { return ZERO_VERSION; diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java index 3b07b41a22..3a96eee92d 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java @@ -112,6 +112,12 @@ public class SQLiteDialect extends Dialect { uniqueDelegate = new SQLiteUniqueDelegate( this ); } + @Override + public int getMaxVarbinaryLength() { + //no varbinary type + return -1; + } + private static class SQLiteUniqueDelegate extends DefaultUniqueDelegate { public SQLiteUniqueDelegate(Dialect dialect) { super( dialect ); diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataDialect.java index b9665d584f..d2d9042efe 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TeradataDialect.java @@ -93,7 +93,7 @@ public class TeradataDialect extends Dialect { registerColumnType( Types.TINYINT, "byteint" ); registerColumnType( Types.BINARY, "byte($l)" ); - registerColumnType( Types.VARBINARY, "varbyte($l)" ); + registerColumnType( Types.VARBINARY, getMaxVarbinaryLength(), "varbyte($l)" ); if ( getVersion().isBefore( 13 ) ) { registerColumnType( Types.BIGINT, "numeric(19,0)" ); @@ -129,6 +129,17 @@ public class TeradataDialect extends Dialect { } + @Override + public int getMaxVarcharLength() { + //for the unicode server character set + return 32_000; + } + + @Override + public int getMaxVarbinaryLength() { + return 64_000; + } + @Override public JdbcType resolveSqlTypeDescriptor( String columnTypeName, int jdbcTypeCode, diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java index 9f43a9862f..155e75f35e 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/TimesTenDialect.java @@ -73,28 +73,28 @@ public class TimesTenDialect extends Dialect { // TypeMode=0 registerColumnType( Types.BOOLEAN, "tt_tinyint" ); - registerColumnType(Types.TINYINT, "tt_tinyint"); - registerColumnType(Types.SMALLINT, "tt_smallint"); - registerColumnType(Types.INTEGER, "tt_integer"); - registerColumnType(Types.BIGINT, "tt_bigint"); + registerColumnType( Types.TINYINT, "tt_tinyint" ); + registerColumnType( Types.SMALLINT, "tt_smallint" ); + registerColumnType( Types.INTEGER, "tt_integer" ); + registerColumnType( Types.BIGINT, "tt_bigint" ); //note that 'binary_float'/'binary_double' might //be better mappings for Java Float/Double //'numeric'/'decimal' are synonyms for 'number' - registerColumnType(Types.NUMERIC, "number($p,$s)"); - registerColumnType(Types.DECIMAL, "number($p,$s)" ); + registerColumnType( Types.NUMERIC, "number($p,$s)" ); + registerColumnType( Types.DECIMAL, "number($p,$s)" ); - registerColumnType( Types.VARCHAR, "varchar2($l)" ); - registerColumnType( Types.NVARCHAR, "nvarchar2($l)" ); + registerColumnType( Types.VARCHAR, getMaxVarcharLength(), "varchar2($l)" ); + registerColumnType( Types.NVARCHAR, getMaxNVarcharLength(), "nvarchar2($l)" ); //do not use 'date' because it's a datetime - registerColumnType(Types.DATE, "tt_date"); + registerColumnType( Types.DATE, "tt_date" ); //'time' and 'tt_time' are synonyms - registerColumnType(Types.TIME, "tt_time"); + registerColumnType( Types.TIME, "tt_time" ); //`timestamp` has more precision than `tt_timestamp` // registerColumnType(Types.TIMESTAMP, "tt_timestamp"); - registerColumnType(Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)"); + registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" ); getDefaultProperties().setProperty( Environment.USE_STREAMS_FOR_BINARY, "true" ); getDefaultProperties().setProperty( Environment.STATEMENT_BATCH_SIZE, DEFAULT_BATCH_SIZE );