Package org.hibernate

Class Length

java.lang.Object
org.hibernate.Length

public final class Length extends Object
Defines a list of useful constant values that may be used to specify long column lengths in the JPA Column annotation.

For example, @Column(length=LONG16) would specify that Hibernate should generate DDL with a column type capable of holding strings with 16-bit lengths.

Since:
6.0
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default length for a column in JPA.
    static final int
    The default length for a LOB column, on databases where LOB columns have a length.
    static final int
    Used to select a variable-length SQL type large enough to contain values of maximum length 32600.
    static final int
    The maximum length that fits in 16 bits.
    static final int
    The maximum length of a Java string or array, that is, the maximum length that fits in 32 bits.
  • Method Summary

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT

      public static final int DEFAULT
      The default length for a column in JPA.
      See Also:
    • LONG

      public static final int LONG
      Used to select a variable-length SQL type large enough to contain values of maximum length 32600. This arbitrary-looking number was chosen because some databases support variable-length types right up to a limit that is just slightly below 32767. (For some, the limit is 32672 characters.)

      This is also the default length for a column declared using @JdbcTypeCode(Types.LONGVARCHAR) or @JdbcTypeCode(Types.LONGVARBINARY).

      For example, @Column(length=LONG) results in the column type:

      varchar(32600)on h2, Db2, and PostgreSQL
      texton MySQL
      clobon Oracle
      varchar(max)on SQL Server
      See Also:
    • LONG16

      public static final int LONG16
      The maximum length that fits in 16 bits. Used to select a variable-length SQL type large enough to accommodate values of maximum length 32767.

      For example, @Column(length=LONG16) results in the column type:

      varchar(32767)on h2 and PostgreSQL
      texton MySQL
      clobon Oracle and Db2
      varchar(max)on SQL Server
      See Also:
    • LONG32

      public static final int LONG32
      The maximum length of a Java string or array, that is, the maximum length that fits in 32 bits. Used to select a variable-length SQL type large enough to accommodate any Java string up to the maximum possible length 2147483647.

      This is also the default length for a column declared using @JdbcTypeCode(SqlTypes.LONG32VARCHAR) or @JdbcTypeCode(SqlTypes.LONG32VARBINARY).

      For example, @Column(length=LONG32) results in the column type:

      texton PostgreSQL
      longtexton MySQL
      clobon h2, Oracle, and Db2
      varchar(max)on SQL Server
      See Also:
    • LOB_DEFAULT

      public static final int LOB_DEFAULT
      The default length for a LOB column, on databases where LOB columns have a length.
      See Also: