Fix MariaDB, DB2 and Derby column type for text type attributes

This commit is contained in:
Andrea Boriero 2021-04-07 16:05:25 +02:00
parent 6f42929b55
commit ae69a1aeb4
4 changed files with 15 additions and 1 deletions

View File

@ -110,6 +110,8 @@ public DB2Dialect(int version) {
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" ); registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp($p)" );
registerColumnType( Types.TIME_WITH_TIMEZONE, "time" ); registerColumnType( Types.TIME_WITH_TIMEZONE, "time" );
registerColumnType( Types.LONGVARCHAR, "long varchar" );
//not keywords, at least not in DB2 11, //not keywords, at least not in DB2 11,
//but perhaps they were in older versions? //but perhaps they were in older versions?
registerKeyword( "current" ); registerKeyword( "current" );

View File

@ -119,6 +119,8 @@ public DerbyDialect(int version) {
registerColumnType( Types.TIMESTAMP, "timestamp" ); registerColumnType( Types.TIMESTAMP, "timestamp" );
registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" ); registerColumnType( Types.TIMESTAMP_WITH_TIMEZONE, "timestamp" );
registerColumnType( Types.LONGVARCHAR, "long varchar" );
registerDerbyKeywords(); registerDerbyKeywords();
limitHandler = getVersion() < 1050 limitHandler = getVersion() < 1050

View File

@ -6,6 +6,8 @@
*/ */
package org.hibernate.dialect; package org.hibernate.dialect;
import java.sql.Types;
import org.hibernate.dialect.sequence.MariaDBSequenceSupport; import org.hibernate.dialect.sequence.MariaDBSequenceSupport;
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;
@ -43,6 +45,10 @@ public MariaDBDialect(int version) {
this.version = version; this.version = version;
} }
protected int getMaxVarcharLen() {
return getMySQLVersion() < 500 ? 255 : 65_534;
}
@Override @Override
public int getVersion() { public int getVersion() {
return version; return version;

View File

@ -117,7 +117,7 @@ else if( "myisam".equalsIgnoreCase( storageEngine ) ) {
} }
// max length for VARCHAR changed in 5.0.3 // max length for VARCHAR changed in 5.0.3
final int maxVarcharLen = getMySQLVersion() < 500 ? 255 : 65_535; final int maxVarcharLen = getMaxVarcharLen();
registerColumnType( Types.VARCHAR, maxVarcharLen, "varchar($l)" ); registerColumnType( Types.VARCHAR, maxVarcharLen, "varchar($l)" );
registerColumnType( Types.VARBINARY, maxVarcharLen, "varbinary($l)" ); registerColumnType( Types.VARBINARY, maxVarcharLen, "varbinary($l)" );
@ -187,6 +187,10 @@ public Size resolveSize(
}; };
} }
protected int getMaxVarcharLen() {
return getMySQLVersion() < 500 ? 255 : 65_535;
}
@Override @Override
public int getVersion() { public int getVersion() {
return version; return version;