make use of Length constants in Dialects instead of Integer.MAX_VALUE

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-26 10:52:56 +02:00
parent d4593b00ce
commit 93ec580fad
9 changed files with 17 additions and 10 deletions

View File

@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.hibernate.Length;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
@ -280,7 +281,7 @@ public class PostgreSQLLegacyDialect extends Dialect {
@Override @Override
public int getMaxVarbinaryLength() { public int getMaxVarbinaryLength() {
//postgres has no varbinary-like type //postgres has no varbinary-like type
return Integer.MAX_VALUE; return Length.LONG32;
} }
@Override @Override

View File

@ -289,7 +289,7 @@ public class SQLServerLegacyDialect extends AbstractTransactSQLDialect {
// this is essentially the only legal length for // this is essentially the only legal length for
// a "lob" in SQL Server, i.e. the value of MAX // a "lob" in SQL Server, i.e. the value of MAX
// (caveat: for NVARCHAR it is half this value) // (caveat: for NVARCHAR it is half this value)
return Integer.MAX_VALUE; return Length.LONG32;
} }
@Override @Override

View File

@ -9,6 +9,7 @@ package org.hibernate.community.dialect;
import java.util.Map; import java.util.Map;
import org.hibernate.Length;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.community.dialect.identity.SybaseAnywhereIdentityColumnSupport; import org.hibernate.community.dialect.identity.SybaseAnywhereIdentityColumnSupport;
@ -103,7 +104,7 @@ public class SybaseAnywhereDialect extends SybaseDialect {
@Override @Override
public int getMaxVarcharLength() { public int getMaxVarcharLength() {
return 32_767; return Length.LONG16;
} }
@Override @Override

View File

@ -4760,7 +4760,7 @@ public abstract class Dialect implements ConversionContext, TypeContributor, Fun
*/ */
public int getMaxVarcharLength() { public int getMaxVarcharLength() {
//the longest possible length of a Java string //the longest possible length of a Java string
return Integer.MAX_VALUE; return Length.LONG32;
} }
/** /**

View File

@ -17,6 +17,7 @@ import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.TimeZone; import java.util.TimeZone;
import org.hibernate.Length;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.FunctionContributions;
@ -534,7 +535,7 @@ public class MySQLDialect extends Dialect {
@Override @Override
public long getDefaultLobLength() { public long getDefaultLobLength() {
return Integer.MAX_VALUE; return Length.LONG32;
} }
@Override @Override

View File

@ -17,6 +17,7 @@ import java.util.TimeZone;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.hibernate.Length;
import org.hibernate.QueryTimeoutException; import org.hibernate.QueryTimeoutException;
import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.FunctionContributions;
import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.TypeContributions;
@ -390,13 +391,13 @@ public class OracleDialect extends Dialect {
@Override @Override
public int getMaxVarcharLength() { public int getMaxVarcharLength() {
//with MAX_STRING_SIZE=EXTENDED, changes to 32_767 //with MAX_STRING_SIZE=EXTENDED, changes to 32_767
return extended ? 32_767 : 4000; return extended ? Length.LONG16 : 4000;
} }
@Override @Override
public int getMaxVarbinaryLength() { public int getMaxVarbinaryLength() {
//with MAX_STRING_SIZE=EXTENDED, changes to 32_767 //with MAX_STRING_SIZE=EXTENDED, changes to 32_767
return extended ? 32_767 : 2000; return extended ? Length.LONG16 : 2000;
} }
@Override @Override

View File

@ -19,6 +19,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TimeZone; import java.util.TimeZone;
import org.hibernate.Length;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.PessimisticLockException; import org.hibernate.PessimisticLockException;
@ -298,7 +299,7 @@ public class PostgreSQLDialect extends Dialect {
@Override @Override
public int getMaxVarbinaryLength() { public int getMaxVarbinaryLength() {
//postgres has no varbinary-like type //postgres has no varbinary-like type
return Integer.MAX_VALUE; return Length.LONG32;
} }
@Override @Override

View File

@ -16,6 +16,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
import org.hibernate.Length;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.QueryTimeoutException; import org.hibernate.QueryTimeoutException;
@ -298,7 +299,7 @@ public class SQLServerDialect extends AbstractTransactSQLDialect {
// this is essentially the only legal length for // this is essentially the only legal length for
// a "lob" in SQL Server, i.e. the value of MAX // a "lob" in SQL Server, i.e. the value of MAX
// (caveat: for NVARCHAR it is half this value) // (caveat: for NVARCHAR it is half this value)
return Integer.MAX_VALUE; return Length.LONG32;
} }
@Override @Override

View File

@ -11,6 +11,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Types; import java.sql.Types;
import org.hibernate.Length;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.LockOptions; import org.hibernate.LockOptions;
import org.hibernate.QueryTimeoutException; import org.hibernate.QueryTimeoutException;
@ -176,7 +177,7 @@ public class SybaseASEDialect extends SybaseDialect {
@Override @Override
public long getDefaultLobLength() { public long getDefaultLobLength() {
return Integer.MAX_VALUE; return Length.LONG32;
} }
private static boolean isAnsiNull(DialectResolutionInfo info) { private static boolean isAnsiNull(DialectResolutionInfo info) {