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 52a7775147..c8498b6cd4 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 @@ -67,9 +67,6 @@ import static org.hibernate.type.SqlTypes.FLOAT; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARBINARY; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARBINARY; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NVARCHAR; import static org.hibernate.type.SqlTypes.TIME; import static org.hibernate.type.SqlTypes.TIMESTAMP; @@ -130,11 +127,8 @@ public class InformixDialect extends Dialect { //these types have no defined length case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "byte"; - case LONGVARCHAR: - case LONGNVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: return "text"; @@ -160,13 +154,13 @@ public class InformixDialect extends Dialect { ); ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( VARCHAR, columnType( LONGVARCHAR ), this ) + CapacityDependentDdlType.builder( VARCHAR, columnType( LONG32VARCHAR ), this ) .withTypeCapacity( 255, "varchar($l)" ) .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) .build() ); ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( NVARCHAR, columnType( LONGNVARCHAR ), this ) + CapacityDependentDdlType.builder( NVARCHAR, columnType( LONG32NVARCHAR ), this ) .withTypeCapacity( 255, "varchar($l)" ) .withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) ) .build() 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 9c937ec979..cc8edf51c3 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 @@ -73,9 +73,6 @@ import static org.hibernate.type.SqlTypes.DECIMAL; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARBINARY; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARBINARY; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NCLOB; import static org.hibernate.type.SqlTypes.NUMERIC; import static org.hibernate.type.SqlTypes.VARBINARY; @@ -157,18 +154,12 @@ public class IngresDialect extends Dialect { case VARBINARY: return "varbyte($l)"; //note: 'long byte' is a synonym for 'blob' - case LONGVARBINARY: - case LONG32VARBINARY: case BLOB: return "long byte($l)"; //note: 'long varchar' is a synonym for 'clob' - case LONGVARCHAR: - case LONG32VARCHAR: case CLOB: return "long varchar($l)"; //note: 'long varchar' is a synonym for 'nclob' - case LONGNVARCHAR: - case LONG32NVARCHAR: case NCLOB: return "long nvarchar($l)"; } diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MimerSQLDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MimerSQLDialect.java index 762a74748b..fb2488d51f 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MimerSQLDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/MimerSQLDialect.java @@ -39,12 +39,11 @@ import org.hibernate.type.descriptor.sql.spi.DdlTypeRegistry; import jakarta.persistence.TemporalType; import static org.hibernate.dialect.SimpleDatabaseVersion.ZERO_VERSION; +import static org.hibernate.type.SqlTypes.BLOB; import static org.hibernate.type.SqlTypes.CHAR; import static org.hibernate.type.SqlTypes.CLOB; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NCHAR; import static org.hibernate.type.SqlTypes.NCLOB; import static org.hibernate.type.SqlTypes.NVARCHAR; @@ -91,12 +90,14 @@ public class MimerSQLDialect extends Dialect { return columnType( NCHAR ); case VARCHAR: return columnType( NVARCHAR ); - case LONGVARCHAR: - return columnType( LONGNVARCHAR ); case LONG32VARCHAR: return columnType( LONG32NVARCHAR ); + //default length is 1M, which is quite low + case BLOB: + return "blob($l)"; case CLOB: - return columnType( NCLOB ); + case NCLOB: + return "nclob($l)"; } return super.columnType( sqlTypeCode ); } @@ -112,12 +113,7 @@ public class MimerSQLDialect extends Dialect { //Mimer CHARs are ASCII!! ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( VARCHAR, columnType( LONGVARCHAR ), "nvarchar(" + getMaxNVarcharLength() + ")", this ) - .withTypeCapacity( getMaxNVarcharLength(), columnType( VARCHAR ) ) - .build() - ); - ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( LONGVARCHAR, columnType( LONGVARCHAR ), "nvarchar(" + getMaxNVarcharLength() + ")", this ) + CapacityDependentDdlType.builder( VARCHAR, columnType( LONG32VARCHAR ), "nvarchar(" + getMaxNVarcharLength() + ")", this ) .withTypeCapacity( getMaxNVarcharLength(), columnType( VARCHAR ) ) .build() ); 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 d873b01c16..5a4a0619df 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 @@ -58,9 +58,6 @@ import static org.hibernate.type.SqlTypes.CLOB; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARBINARY; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARBINARY; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NCHAR; import static org.hibernate.type.SqlTypes.NCLOB; import static org.hibernate.type.SqlTypes.NVARCHAR; @@ -142,9 +139,7 @@ public class RDMSOS2200Dialect extends Dialect { case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: case LONG32VARCHAR: - case LONGNVARCHAR: case LONG32NVARCHAR: return "unicode($l)"; case CLOB: @@ -153,7 +148,6 @@ public class RDMSOS2200Dialect extends Dialect { //no 'binary' nor 'varbinary' so use 'blob' case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: case BLOB: return "blob($l)"; diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereDialect.java index 07f843a787..5f9cb2b835 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SybaseAnywhereDialect.java @@ -52,16 +52,23 @@ public class SybaseAnywhereDialect extends SybaseDialect { @Override protected String columnType(int sqlTypeCode) { switch ( sqlTypeCode ) { + case DATE: + return "date"; + case TIME: + return "time"; case TIMESTAMP: return "timestamp"; case TIMESTAMP_WITH_TIMEZONE: return "timestamp with time zone"; + + //these types hold up to 2 GB case LONG32VARCHAR: return "long varchar"; case LONG32NVARCHAR: return "long nvarchar"; case LONG32VARBINARY: return "long binary"; + case NCLOB: return "ntext"; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java index f419a4f870..a150cfe9ab 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractHANADialect.java @@ -92,8 +92,6 @@ import static org.hibernate.type.SqlTypes.DOUBLE; import static org.hibernate.type.SqlTypes.GEOMETRY; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NCHAR; import static org.hibernate.type.SqlTypes.NCLOB; import static org.hibernate.type.SqlTypes.NUMERIC; @@ -220,8 +218,6 @@ public abstract class AbstractHANADialect extends Dialect { return columnType( NVARCHAR ); case LONG32VARCHAR: return isUseUnicodeStringTypes() ? columnType( LONG32NVARCHAR ) : super.columnType( LONG32VARCHAR ); - case LONGVARCHAR: - return isUseUnicodeStringTypes() ? columnType( LONGNVARCHAR ) : super.columnType( LONGVARCHAR ); case CLOB: return isUseUnicodeStringTypes() ? columnType( NCLOB ) : super.columnType( CLOB ); // map tinyint to smallint since tinyint is unsigned on HANA diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java index 739962fe8b..792f4f0131 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java @@ -65,6 +65,7 @@ public abstract class AbstractTransactSQLDialect extends Dialect { switch ( sqlTypeCode ) { case BOOLEAN: return "bit"; + case TINYINT: //'tinyint' is an unsigned type in Sybase and //SQL Server, holding values in the range 0-255 @@ -73,17 +74,20 @@ public abstract class AbstractTransactSQLDialect extends Dialect { case INTEGER: //it's called 'int' not 'integer' return "int"; + case DATE: case TIME: - case TIME_WITH_TIMEZONE: case TIMESTAMP: + case TIME_WITH_TIMEZONE: case TIMESTAMP_WITH_TIMEZONE: return "datetime"; + case BLOB: return "image"; case CLOB: - case NCLOB: return "text"; + case NCLOB: + return "ntext"; } return super.columnType( sqlTypeCode ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/CockroachDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/CockroachDialect.java index 9e4479059f..cc205a92ee 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/CockroachDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/CockroachDialect.java @@ -96,24 +96,21 @@ public class CockroachDialect extends Dialect { switch ( sqlTypeCode ) { case TINYINT: return "smallint"; //no tinyint + case CHAR: case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: return "string($l)"; - case CLOB: + case NCLOB: - case LONG32VARCHAR: - case LONG32NVARCHAR: + case CLOB: return "string"; + case BINARY: case VARBINARY: - case LONGVARBINARY: return "bytes($l)"; case BLOB: - case LONG32VARBINARY: return "bytes"; } return super.columnType( sqlTypeCode ); @@ -126,14 +123,11 @@ public class CockroachDialect extends Dialect { case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: return "string"; case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "bytes"; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index 5a35288cbe..3d2f7f784d 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -120,22 +120,20 @@ public class DerbyDialect extends Dialect { case TINYINT: //no tinyint return "smallint"; + case NUMERIC: // HHH-12827: map them both to the same type to avoid problems with schema update // Note that 31 is the maximum precision Derby supports return columnType( DECIMAL ); + case VARBINARY: return "varchar($l) for bit data"; - case LONGVARBINARY: case LONG32VARBINARY: return "long varchar for bit data"; case NCHAR: return columnType( CHAR ); case NVARCHAR: return columnType( VARCHAR ); - case LONGNVARCHAR: - return columnType( LONGVARCHAR ); - case LONGVARCHAR: case LONG32VARCHAR: return "long varchar"; case BLOB: @@ -161,19 +159,19 @@ public class DerbyDialect extends Dialect { ddlTypeRegistry.addDescriptor( CapacityDependentDdlType.builder( VARBINARY, columnType( BLOB ), columnType( VARBINARY ), this ) .withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGVARBINARY ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARBINARY ) ) .build() ); ddlTypeRegistry.addDescriptor( CapacityDependentDdlType.builder( VARCHAR, columnType( CLOB ), columnType( VARCHAR ), this ) .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGVARCHAR ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) ) .build() ); ddlTypeRegistry.addDescriptor( CapacityDependentDdlType.builder( NVARCHAR, columnType( CLOB ), columnType( NVARCHAR ), this ) .withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGVARCHAR ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) ) .build() ); @@ -181,7 +179,7 @@ public class DerbyDialect extends Dialect { CapacityDependentDdlType.builder( BINARY, columnType( BLOB ), columnType( VARBINARY ), this ) .withTypeCapacity( 254, "char($l) for bit data" ) .withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGVARBINARY ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARBINARY ) ) .build() ); @@ -190,14 +188,14 @@ public class DerbyDialect extends Dialect { CapacityDependentDdlType.builder( CHAR, columnType( CLOB ), columnType( CHAR ), this ) .withTypeCapacity( 254, columnType( CHAR ) ) .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGVARCHAR ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32VARCHAR ) ) .build() ); ddlTypeRegistry.addDescriptor( CapacityDependentDdlType.builder( NCHAR, columnType( CLOB ), columnType( NCHAR ), this ) .withTypeCapacity( 254, columnType( NCHAR ) ) .withTypeCapacity( getMaxVarcharLength(), columnType( NVARCHAR ) ) - .withTypeCapacity( maxLongVarcharLength, columnType( LONGNVARCHAR ) ) + .withTypeCapacity( maxLongVarcharLength, columnType( LONG32NVARCHAR ) ) .build() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index decfbf8432..515bf9ca3f 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -309,12 +309,7 @@ public abstract class Dialect implements ConversionContext { ddlTypeRegistry.addDescriptor( simpleSqlType( CHAR ) ); ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( VARCHAR, LONGVARCHAR, VARCHAR ) - .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) - .build() - ); - ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( LONGVARCHAR, LONGVARCHAR, VARCHAR ) + sqlTypeBuilder( VARCHAR, LONG32VARCHAR, VARCHAR ) .withTypeCapacity( getMaxVarcharLength(), columnType( VARCHAR ) ) .build() ); @@ -322,12 +317,7 @@ public abstract class Dialect implements ConversionContext { ddlTypeRegistry.addDescriptor( simpleSqlType( NCHAR ) ); ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( NVARCHAR, LONGNVARCHAR, NVARCHAR ) - .withTypeCapacity( getMaxNVarcharLength(), columnType( NVARCHAR ) ) - .build() - ); - ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( LONGNVARCHAR, LONGNVARCHAR, NVARCHAR ) + sqlTypeBuilder( NVARCHAR, LONG32NVARCHAR, NVARCHAR ) .withTypeCapacity( getMaxNVarcharLength(), columnType( NVARCHAR ) ) .build() ); @@ -335,12 +325,7 @@ public abstract class Dialect implements ConversionContext { ddlTypeRegistry.addDescriptor( simpleSqlType( BINARY ) ); ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( VARBINARY, LONGVARBINARY, VARBINARY ) - .withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) - .build() - ); - ddlTypeRegistry.addDescriptor( - sqlTypeBuilder( LONGVARBINARY, LONGVARBINARY, VARBINARY ) + sqlTypeBuilder( VARBINARY, LONG32VARBINARY, VARBINARY ) .withTypeCapacity( getMaxVarbinaryLength(), columnType( VARBINARY ) ) .build() ); @@ -448,13 +433,10 @@ public abstract class Dialect implements ConversionContext { return "blob"; // by default use the LOB mappings for the "long" types - case LONGVARCHAR: case LONG32VARCHAR: return columnType( CLOB ); - case LONGNVARCHAR: case LONG32NVARCHAR: return columnType( NCLOB ); - case LONGVARBINARY: case LONG32VARBINARY: return columnType( BLOB ); diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index b3c8bf5d86..89ab5f7a7c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -78,9 +78,6 @@ import static org.hibernate.type.SqlTypes.INTERVAL_SECOND; import static org.hibernate.type.SqlTypes.LONG32NVARCHAR; import static org.hibernate.type.SqlTypes.LONG32VARBINARY; import static org.hibernate.type.SqlTypes.LONG32VARCHAR; -import static org.hibernate.type.SqlTypes.LONGNVARCHAR; -import static org.hibernate.type.SqlTypes.LONGVARBINARY; -import static org.hibernate.type.SqlTypes.LONGVARCHAR; import static org.hibernate.type.SqlTypes.NCHAR; import static org.hibernate.type.SqlTypes.NUMERIC; import static org.hibernate.type.SqlTypes.NVARCHAR; @@ -179,12 +176,9 @@ public class H2Dialect extends Dialect { case NCHAR: return columnType( CHAR ); case NVARCHAR: - case LONGNVARCHAR: case LONG32NVARCHAR: - case LONGVARCHAR: case LONG32VARCHAR: return columnType( VARCHAR ); - case LONGVARBINARY: case LONG32VARBINARY: return columnType( VARBINARY ); } @@ -199,14 +193,11 @@ public class H2Dialect extends Dialect { return "char"; case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: return "varchar"; case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "varbinary"; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java index fbfe4790cb..ce35384914 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java @@ -132,13 +132,16 @@ public class HSQLDialect extends Dialect { // Older versions of HSQL did not accept // precision for the 'numeric' type return "numeric"; + // Older versions of HSQL had no lob support case BLOB: return "longvarbinary"; case CLOB: return "longvarchar"; + } } + return super.columnType( sqlTypeCode ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java index b1d19b8c4a..643ac5d82e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java @@ -158,10 +158,13 @@ public class MySQLDialect extends Dialect { case BOOLEAN: // HHH-6935: Don't use "boolean" i.e. tinyint(1) due to JDBC ResultSetMetaData return "bit"; + case TIMESTAMP: - return getMySQLVersion().isBefore( 5, 7 ) ? "datetime" : "datetime($p)"; + return getMySQLVersion().isBefore( 5, 7 ) + ? "datetime" : "datetime($p)"; case TIMESTAMP_WITH_TIMEZONE: - return getMySQLVersion().isBefore( 5, 7 ) ? "timestamp" : "timestamp($p)"; + return getMySQLVersion().isBefore( 5, 7 ) + ? "timestamp" : "timestamp($p)"; case NUMERIC: // it's just a synonym return columnType( DECIMAL ); @@ -199,15 +202,12 @@ public class MySQLDialect extends Dialect { case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: //MySQL doesn't let you cast to TEXT/LONGTEXT return "char"; case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: //MySQL doesn't let you cast to BLOB/TINYBLOB/LONGBLOB return "binary"; @@ -275,34 +275,8 @@ public class MySQLDialect extends Dialect { } ddlTypeRegistry.addDescriptor( varbinaryBuilder.build() ); - ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( LONGVARBINARY, columnType( BLOB ), "binary", this ) - .withTypeCapacity( maxTinyLobLen, "tinyblob" ) - .withTypeCapacity( maxMediumLobLen, "mediumblob" ) - .withTypeCapacity( maxLobLen, "blob" ) - .build() - ); - ddlTypeRegistry.addDescriptor( new DdlTypeImpl( LONG32VARBINARY, columnType( BLOB ), "binary", this ) ); - - ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( LONGVARCHAR, columnType( CLOB ), "char", this ) - .withTypeCapacity( maxTinyLobLen, "tinytext" ) - .withTypeCapacity( maxMediumLobLen, "mediumtext" ) - .withTypeCapacity( maxLobLen, "text" ) - .build() - ); - ddlTypeRegistry.addDescriptor( new DdlTypeImpl( LONG32VARCHAR, columnType( CLOB ), "char", this ) ); - - ddlTypeRegistry.addDescriptor( - CapacityDependentDdlType.builder( LONGNVARCHAR, columnType( NCLOB ), "char", this ) - .withTypeCapacity( maxTinyLobLen, "tinytext" ) - .withTypeCapacity( maxMediumLobLen, "mediumtext" ) - .withTypeCapacity( maxLobLen, "text" ) - .build() - ); - ddlTypeRegistry.addDescriptor( new DdlTypeImpl( LONG32NVARCHAR, columnType( CLOB ), "char", this ) ); ddlTypeRegistry.addDescriptor( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java index f48796e41c..fc25fc731a 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/OracleDialect.java @@ -554,6 +554,7 @@ public class OracleDialect extends Dialect { case BOOLEAN: // still, after all these years... return "number(1,0)"; + case TINYINT: return "number(3,0)"; case SMALLINT: @@ -565,10 +566,12 @@ public class OracleDialect extends Dialect { case REAL: // Oracle's 'real' type is actually double precision return "float(24)"; + case NUMERIC: case DECIMAL: // Note that 38 is the maximum precision Oracle supports return "number($p,$s)"; + case DATE: case TIME: return "date"; @@ -577,6 +580,8 @@ public class OracleDialect extends Dialect { // on Oracle is that date has no fractional seconds case TIMESTAMP_WITH_TIMEZONE: return getVersion().isBefore( 9 ) ? "date" : super.columnType( sqlTypeCode ); + case TIME_WITH_TIMEZONE: + return getVersion().isBefore( 9 ) ? "date" : "timestamp($p) with time zone"; case VARCHAR: return getVersion().isBefore( 9 ) ? "varchar2($l)" : "varchar2($l char)"; case NVARCHAR: diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java index 2d95459e0b..60ba0409f7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQLDialect.java @@ -131,22 +131,27 @@ public class PostgreSQLDialect extends Dialect { case TINYINT: // no tinyint, not even in Postgres 11 return "smallint"; + // there are no nchar/nvarchar types in Postgres case NCHAR: return columnType( CHAR ); case NVARCHAR: return columnType( VARCHAR ); - case LONGVARCHAR: + // since there's no real difference between TEXT and VARCHAR, + // except for the length limit, we can just use 'text' for the + // "long" string types case LONG32VARCHAR: - case LONGNVARCHAR: case LONG32NVARCHAR: return "text"; case BLOB: case CLOB: case NCLOB: + // use oid as the blob type on Postgres because + // the JDBC driver is rubbish return "oid"; + // use bytea as the "long" binary type (that there is no + // real VARBINARY type in Postgres, so we always use this) case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "bytea"; } @@ -160,14 +165,11 @@ public class PostgreSQLDialect extends Dialect { case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: case LONG32VARCHAR: - case LONGNVARCHAR: case LONG32NVARCHAR: return "text"; case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "bytea"; } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java index 9fe615c6f5..0fd68febe7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SQLServerDialect.java @@ -125,16 +125,10 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { // be either between 1 and 8000 or exactly MAX, and // the length of an NVARCHAR column must be either // between 1 and 4000 or exactly MAX. (HHH-3965) - case LONGVARCHAR: - case LONG32VARCHAR: case CLOB: return "varchar(max)"; - case LONGNVARCHAR: - case LONG32NVARCHAR: case NCLOB: return "nvarchar(max)"; - case LONGVARBINARY: - case LONG32VARBINARY: case BLOB: return "varbinary(max)"; case DATE: @@ -155,17 +149,14 @@ public class SQLServerDialect extends AbstractTransactSQLDialect { if ( getVersion().isSameOrAfter( 9 ) ) { switch ( sqlTypeCode ) { case VARCHAR: - case LONGVARCHAR: case LONG32VARCHAR: case CLOB: return "varchar(max)"; case NVARCHAR: - case LONGNVARCHAR: case LONG32NVARCHAR: case NCLOB: return "nvarchar(max)"; case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: case BLOB: return "varbinary(max)"; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java index 33bfb033d9..d34713a53c 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SpannerDialect.java @@ -84,41 +84,41 @@ public class SpannerDialect extends Dialect { switch ( sqlTypeCode ) { case BOOLEAN: return "bool"; + case TINYINT: case SMALLINT: case INTEGER: case BIGINT: return "int64"; + case REAL: case FLOAT: case DOUBLE: case DECIMAL: case NUMERIC: return "float64"; + //there is no time type of any kind case TIME: //timestamp does not accept precision case TIMESTAMP: case TIMESTAMP_WITH_TIMEZONE: return "timestamp"; + case CHAR: case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: return "string($l)"; - case CLOB: - case NCLOB: - case LONG32VARCHAR: - case LONG32NVARCHAR: - return "string(max)"; + case BINARY: case VARBINARY: - case LONGVARBINARY: return "bytes($l)"; + + case CLOB: + case NCLOB: + return "string(max)"; case BLOB: - case LONG32VARBINARY: return "bytes(max)"; } return super.columnType( sqlTypeCode ); @@ -131,14 +131,11 @@ public class SpannerDialect extends Dialect { case NCHAR: case VARCHAR: case NVARCHAR: - case LONGVARCHAR: - case LONGNVARCHAR: case LONG32VARCHAR: case LONG32NVARCHAR: return "string"; case BINARY: case VARBINARY: - case LONGVARBINARY: case LONG32VARBINARY: return "bytes"; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java index 12878d916b..01eb2929ff 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/spi/DdlTypeRegistry.java @@ -60,8 +60,33 @@ public class DdlTypeRegistry implements Serializable { ddlTypes.putIfAbsent( sqlTypeCode, jdbcType ); } + /** + * Returns the registered {@link DdlType} for the given SQL type code. + *
+ * Not that the "long" types {@link Types#LONGVARCHAR}, {@link Types#LONGNVARCHAR} + * and {@link Types#LONGVARBINARY} are considered synonyms for their + * non-{@code LONG} counterparts, with the only difference being that + * a different default length is used: {@link org.hibernate.Length#LONG} + * instead of {@link org.hibernate.Length#DEFAULT}. + * + */ public DdlType getDescriptor(int sqlTypeCode) { - return ddlTypes.get( sqlTypeCode ); + final DdlType ddlType = ddlTypes.get( sqlTypeCode ); + if ( ddlType == null ) { + switch ( sqlTypeCode ) { + // these are no longer considered separate column types as such + // they're just used to indicate that JavaType.getLongSqlLength() + // should be used by default (and that's already handled by the + // time we get to here) + case Types.LONGVARCHAR: + return ddlTypes.get( Types.VARCHAR ); + case Types.LONGNVARCHAR: + return ddlTypes.get( Types.NVARCHAR ); + case Types.LONGVARBINARY: + return ddlTypes.get( Types.VARBINARY ); + } + } + return ddlType; } public String getTypeName(int typeCode, Dialect dialect) {