All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.Length Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-License-Identifier: LGPL-2.1-or-later
 * Copyright Red Hat Inc. and Hibernate Authors
 */
package org.hibernate;

/**
 * Defines a list of useful constant values that may be used
 * to specify long column lengths in the JPA
 * {@link jakarta.persistence.Column} annotation.
 * 

* For example, {@code @Column(length=LONG16)} would specify * that Hibernate should generate DDL with a column type * capable of holding strings with 16-bit lengths. * * @see jakarta.persistence.Column#length() * * @since 6.0 * @author Gavin King */ public final class Length { /** * The default length for a column in JPA. * * @see jakarta.persistence.Column#length() * @see org.hibernate.type.descriptor.java.JavaType#getDefaultSqlLength */ public static final int DEFAULT = 255; /** * 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 * {@code @JdbcTypeCode(Types.LONGVARCHAR)} or * {@code @JdbcTypeCode(Types.LONGVARBINARY)}. *

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

* * * * *
{@code varchar(32600)}on h2, Db2, and PostgreSQL
{@code text}on MySQL
{@code clob}on Oracle
{@code varchar(max)}on SQL Server
* * @see org.hibernate.type.descriptor.java.JavaType#getLongSqlLength * * @see org.hibernate.type.SqlTypes#LONGVARCHAR * @see org.hibernate.type.SqlTypes#LONGVARBINARY */ public static final int LONG = 32_600; /** * The maximum length that fits in 16 bits. * Used to select a variable-length SQL type large * enough to accommodate values of maximum length * {@value Short#MAX_VALUE}. *

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

* * * * *
{@code varchar(32767)}on h2 and PostgreSQL
{@code text}on MySQL
{@code clob}on Oracle and Db2
{@code varchar(max)}on SQL Server
*/ public static final int LONG16 = Short.MAX_VALUE; /** * 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 {@value Integer#MAX_VALUE}. *

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

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

* * * * *
{@code text}on PostgreSQL
{@code longtext}on MySQL
{@code clob}on h2, Oracle, and Db2
{@code varchar(max)}on SQL Server
* * @see org.hibernate.type.SqlTypes#LONG32VARCHAR * @see org.hibernate.type.SqlTypes#LONG32VARBINARY */ public static final int LONG32 = Integer.MAX_VALUE; /** * The default length for a LOB column, on databases * where LOB columns have a length. * * @see org.hibernate.dialect.Dialect#getDefaultLobLength * * @see org.hibernate.type.SqlTypes#CLOB * @see org.hibernate.type.SqlTypes#BLOB */ public static final int LOB_DEFAULT = 1_048_576; private Length() {} }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy