some cleanups + doc for SqlTypes
This commit is contained in:
parent
5dfb90bb73
commit
77a1be10b1
|
@ -42,7 +42,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
* <p/>
|
||||
* This code is generally as one of the values defined in {@link java.sql.Types}, but are not
|
||||
* limited to these. The code is resolved against an internal registry of {@link JdbcType}
|
||||
* references. See the user-guide for additional details.
|
||||
* references. See the user guide for additional details.
|
||||
* <p/>
|
||||
* See <a href="package-summary.html#basic-value-mapping"/> for high-level discussion
|
||||
* of basic value mapping.
|
||||
|
@ -61,8 +61,8 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|||
public @interface JdbcTypeCode {
|
||||
/**
|
||||
* The standard {@linkplain java.sql.Types JDBC Types} code or a custom code.
|
||||
* This ultimately decides which {@link JdbcType}
|
||||
* is used to "understand" the described SQL data type
|
||||
* This ultimately decides which {@link JdbcType} is used to "understand" the
|
||||
* described SQL data type.
|
||||
*/
|
||||
int value();
|
||||
}
|
||||
|
|
|
@ -9,71 +9,71 @@ package org.hibernate.type;
|
|||
import java.sql.Types;
|
||||
|
||||
/**
|
||||
* The class that defines the constants that are used to identify generic
|
||||
* SQL types. This is an extension of {@link Types} that provides type codes
|
||||
* for types that Hibernate supports in addition to the standard JDBC types.
|
||||
* Defines a list of constant type codes used to identify generic SQL types.
|
||||
* This is an extension of the standard JDBC-defined {@link Types}, defining
|
||||
* additional type codes for types that Hibernate supports but which are not
|
||||
* recognized by the JDBC specification.
|
||||
* <p>
|
||||
* Each of these type codes represents an abstraction over a family of
|
||||
* similar types in different databases. It's the job of the SQL
|
||||
* {@link org.hibernate.dialect.Dialect}, and in particular of the method
|
||||
* {@code columnType()}, to interpret these type codes as column type names.
|
||||
* <p>
|
||||
* A type code is often used as a key to obtain a
|
||||
* {@link org.hibernate.type.descriptor.jdbc.JdbcType}, by implementors of
|
||||
* {@link org.hibernate.type.descriptor.java.JavaType#getRecommendedJdbcType},
|
||||
* or when the {@link org.hibernate.annotations.JdbcTypeCode @JdbcTypeCode}
|
||||
* annotation is used, for example.
|
||||
*
|
||||
* @see org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry
|
||||
*
|
||||
* @author Christian Beikov
|
||||
*/
|
||||
public class SqlTypes {
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code BIT}.
|
||||
* A type code representing generic SQL type {@code BIT}.
|
||||
*
|
||||
* @see Types#BIT
|
||||
*/
|
||||
public final static int BIT = Types.BIT;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code TINYINT}.
|
||||
* A type code representing the generic SQL type {@code TINYINT}.
|
||||
*
|
||||
* @see Types#TINYINT
|
||||
*/
|
||||
public final static int TINYINT = Types.TINYINT;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code SMALLINT}.
|
||||
* A type code representing the generic SQL type {@code SMALLINT}.
|
||||
*
|
||||
* @see Types#SMALLINT
|
||||
*/
|
||||
public final static int SMALLINT = Types.SMALLINT;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code INTEGER}.
|
||||
* A type code representing the generic SQL type {@code INTEGER}.
|
||||
*
|
||||
* @see Types#INTEGER
|
||||
*/
|
||||
public final static int INTEGER = Types.INTEGER;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code BIGINT}.
|
||||
* A type code representing the generic SQL type {@code BIGINT}.
|
||||
*
|
||||
* @see Types#BIGINT
|
||||
*/
|
||||
public final static int BIGINT = Types.BIGINT;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code FLOAT}.
|
||||
* A type code representing the generic SQL type {@code FLOAT}.
|
||||
*
|
||||
* @see Types#FLOAT
|
||||
*/
|
||||
public final static int FLOAT = Types.FLOAT;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code REAL}.
|
||||
* A type code representing the generic SQL type {@code REAL}.
|
||||
*
|
||||
* @see Types#REAL
|
||||
*/
|
||||
|
@ -81,54 +81,42 @@ public class SqlTypes {
|
|||
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code DOUBLE}.
|
||||
* A type code representing the generic SQL type {@code DOUBLE}.
|
||||
*
|
||||
* @see Types#DOUBLE
|
||||
*/
|
||||
public final static int DOUBLE = Types.DOUBLE;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code NUMERIC}.
|
||||
* A type code representing the generic SQL type {@code NUMERIC}.
|
||||
*
|
||||
* @see Types#NUMERIC
|
||||
*/
|
||||
public final static int NUMERIC = Types.NUMERIC;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code DECIMAL}.
|
||||
* A type code representing the generic SQL type {@code DECIMAL}.
|
||||
*
|
||||
* @see Types#DECIMAL
|
||||
*/
|
||||
public final static int DECIMAL = Types.DECIMAL;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code CHAR}.
|
||||
* A type code representing the generic SQL type {@code CHAR}.
|
||||
*
|
||||
* @see Types#CHAR
|
||||
*/
|
||||
public final static int CHAR = Types.CHAR;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code VARCHAR}.
|
||||
* A type code representing the generic SQL type {@code VARCHAR}.
|
||||
*
|
||||
* @see Types#VARCHAR
|
||||
*/
|
||||
public final static int VARCHAR = Types.VARCHAR;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code LONGVARCHAR}.
|
||||
* A type code representing the generic SQL type {@code LONGVARCHAR}.
|
||||
* <p>
|
||||
* Interpreted by Hibernate as a {@link #VARCHAR}-like type large enough
|
||||
* to hold a string of maximum length {@link org.hibernate.Length#LONG}.
|
||||
|
@ -149,54 +137,42 @@ public class SqlTypes {
|
|||
public final static int LONG32VARCHAR = 4001;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code DATE}.
|
||||
* A type code representing the generic SQL type {@code DATE}.
|
||||
*
|
||||
* @see Types#DATE
|
||||
*/
|
||||
public final static int DATE = Types.DATE;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code TIME}.
|
||||
* A type code representing the generic SQL type {@code TIME}.
|
||||
*
|
||||
* @see Types#TIME
|
||||
*/
|
||||
public final static int TIME = Types.TIME;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code TIMESTAMP}.
|
||||
* A type code representing the generic SQL type {@code TIMESTAMP}.
|
||||
*
|
||||
* @see Types#TIMESTAMP
|
||||
*/
|
||||
public final static int TIMESTAMP = Types.TIMESTAMP;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code BINARY}.
|
||||
* A type code representing the generic SQL type {@code BINARY}.
|
||||
*
|
||||
* @see Types#BINARY
|
||||
*/
|
||||
public final static int BINARY = Types.BINARY;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code VARBINARY}.
|
||||
* A type code representing the generic SQL type {@code VARBINARY}.
|
||||
*
|
||||
* @see Types#VARBINARY
|
||||
*/
|
||||
public final static int VARBINARY = Types.VARBINARY;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language, sometimes referred
|
||||
* to as a type code, that identifies the generic SQL type
|
||||
* {@code LONGVARBINARY}.
|
||||
* A type code representing the generic SQL type {@code LONGVARBINARY}.
|
||||
* <p>
|
||||
* Interpreted by Hibernate as a {@link #VARBINARY}-like type large enough
|
||||
* to hold a byte array of maximum length {@link org.hibernate.Length#LONG}.
|
||||
|
@ -208,8 +184,8 @@ public class SqlTypes {
|
|||
public final static int LONGVARBINARY = Types.LONGVARBINARY;
|
||||
|
||||
/**
|
||||
* A type code used internally by the Hibernate
|
||||
* {@link org.hibernate.dialect.Dialect} to identify a
|
||||
* A type code used internally by the Hibernate SQL
|
||||
* {@linkplain org.hibernate.dialect.Dialect dialect} to identify a
|
||||
* {@link #VARBINARY}-like type large enough to hold any Java byte array.
|
||||
*
|
||||
* @see org.hibernate.Length#LONG32
|
||||
|
@ -217,18 +193,16 @@ public class SqlTypes {
|
|||
public final static int LONG32VARBINARY = 4003;
|
||||
|
||||
/**
|
||||
* <P>The constant in the Java programming language
|
||||
* that identifies the generic SQL value
|
||||
* {@code NULL}.
|
||||
* A type code representing the generic SQL value {@code NULL}.
|
||||
*
|
||||
* @see Types#NULL
|
||||
*/
|
||||
public final static int NULL = Types.NULL;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language that indicates that the
|
||||
* SQL type is database-specific and is mapped to a Java object that can
|
||||
* be accessed via the methods {@link java.sql.ResultSet#getObject} and
|
||||
* A type code indicating that the SQL type is SQL dialect-specific
|
||||
* and is mapped to a Java object that can be accessed via the methods
|
||||
* {@link java.sql.ResultSet#getObject} and
|
||||
* {@link java.sql.PreparedStatement#setObject}.
|
||||
*
|
||||
* @see Types#OTHER
|
||||
|
@ -236,105 +210,91 @@ public class SqlTypes {
|
|||
public final static int OTHER = Types.OTHER;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type
|
||||
* {@code JAVA_OBJECT}.
|
||||
* A type code representing the generic SQL type {@code JAVA_OBJECT}.
|
||||
*
|
||||
* @see Types#JAVA_OBJECT
|
||||
*/
|
||||
public final static int JAVA_OBJECT = Types.JAVA_OBJECT;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code DISTINCT}.
|
||||
* A type code representing the generic SQL type {@code DISTINCT}.
|
||||
*
|
||||
* @see Types#DISTINCT
|
||||
*/
|
||||
public final static int DISTINCT = Types.DISTINCT;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code STRUCT}.
|
||||
* A type code representing the generic SQL type {@code STRUCT}.
|
||||
*
|
||||
* @see Types#STRUCT
|
||||
*/
|
||||
public final static int STRUCT = Types.STRUCT;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code ARRAY}.
|
||||
* A type code representing the generic SQL type {@code ARRAY}.
|
||||
*
|
||||
* @see Types#ARRAY
|
||||
*/
|
||||
public final static int ARRAY = Types.ARRAY;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code BLOB}.
|
||||
* A type code representing the generic SQL type {@code BLOB}.
|
||||
*
|
||||
* @see Types#ARRAY
|
||||
*/
|
||||
public final static int BLOB = Types.BLOB;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code CLOB}.
|
||||
* A type code representing the generic SQL type {@code CLOB}.
|
||||
*
|
||||
* @see Types#CLOB
|
||||
*/
|
||||
public final static int CLOB = Types.CLOB;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code REF}.
|
||||
* A type code representing the generic SQL type {@code REF}.
|
||||
*
|
||||
* @see Types#REF
|
||||
*/
|
||||
public final static int REF = Types.REF;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, somtimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code DATALINK}.
|
||||
* A type code representing the generic SQL type {@code DATALINK}.
|
||||
*
|
||||
* @see Types#DATALINK
|
||||
*/
|
||||
public final static int DATALINK = Types.DATALINK;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, somtimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code BOOLEAN}.
|
||||
* A type code representing the generic SQL type {@code BOOLEAN}.
|
||||
*
|
||||
* @see Types#BOOLEAN
|
||||
*/
|
||||
public final static int BOOLEAN = Types.BOOLEAN;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code ROWID}
|
||||
* A type code representing the generic SQL type {@code ROWID}.
|
||||
*
|
||||
* @see Types#ROWID
|
||||
*/
|
||||
public final static int ROWID = Types.ROWID;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code NCHAR}
|
||||
* A type code representing the generic SQL type {@code NCHAR}.
|
||||
*
|
||||
* @see Types#NCHAR
|
||||
*/
|
||||
public static final int NCHAR = Types.NCHAR;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code NVARCHAR}.
|
||||
* A type code representing the generic SQL type {@code NVARCHAR}.
|
||||
*
|
||||
* @see Types#NVARCHAR
|
||||
*/
|
||||
public static final int NVARCHAR = Types.NVARCHAR;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code LONGNVARCHAR}.
|
||||
* A type code representing the generic SQL type {@code LONGNVARCHAR}.
|
||||
* <p>
|
||||
* Interpreted by Hibernate as an {@link #NVARCHAR}-like type large enough
|
||||
* to hold a string of maximum length {@link org.hibernate.Length#LONG}.
|
||||
|
@ -355,32 +315,28 @@ public class SqlTypes {
|
|||
public final static int LONG32NVARCHAR = 4002;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code NCLOB}.
|
||||
* A type code representing the generic SQL type {@code NCLOB}.
|
||||
*
|
||||
* @see Types#NCLOB
|
||||
*/
|
||||
public static final int NCLOB = Types.NCLOB;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code XML}.
|
||||
* A type code representing the generic SQL type {@code XML}.
|
||||
*
|
||||
* @see Types#SQLXML
|
||||
*/
|
||||
public static final int SQLXML = Types.SQLXML;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code REF CURSOR}.
|
||||
* A type code representing the generic SQL type {@code REF CURSOR}.
|
||||
*
|
||||
* @see Types#REF_CURSOR
|
||||
*/
|
||||
public static final int REF_CURSOR = Types.REF_CURSOR;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type
|
||||
* A type code representing identifies the generic SQL type
|
||||
* {@code TIME WITH TIMEZONE}.
|
||||
*
|
||||
* @see Types#TIME_WITH_TIMEZONE
|
||||
|
@ -388,8 +344,7 @@ public class SqlTypes {
|
|||
public static final int TIME_WITH_TIMEZONE = Types.TIME_WITH_TIMEZONE;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type
|
||||
* A type code representing the generic SQL type
|
||||
* {@code TIMESTAMP WITH TIMEZONE}.
|
||||
*
|
||||
* @see Types#TIMESTAMP_WITH_TIMEZONE
|
||||
|
@ -399,60 +354,53 @@ public class SqlTypes {
|
|||
// Misc types
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code UUID}.
|
||||
* A type code representing the generic SQL type {@code UUID}.
|
||||
*
|
||||
* @see org.hibernate.cfg.AvailableSettings#PREFERRED_UUID_JDBC_TYPE
|
||||
*/
|
||||
public static final int UUID = 3000;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code JSON}.
|
||||
* A type code representing the generic SQL type {@code JSON}.
|
||||
*/
|
||||
public static final int JSON = 3001;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code INET}
|
||||
* for IPv4 or IPv6 addresses.
|
||||
* A type code representing the generic SQL type {@code INET} for IPv4
|
||||
* or IPv6 addresses.
|
||||
*/
|
||||
public static final int INET = 3002;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type
|
||||
* {@code TIMESTAMP_UTC}.
|
||||
* A type code representing the generic SQL type {@code TIMESTAMP},
|
||||
* where the value is given in UTC, instead of in the system or
|
||||
* {@linkplain org.hibernate.cfg.AvailableSettings#JDBC_TIME_ZONE
|
||||
* JDBC} timezone.
|
||||
*/
|
||||
public static final int TIMESTAMP_UTC = 3003;
|
||||
|
||||
// Interval types
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type
|
||||
* {@code INTERVAL SECOND} for a temporal amount in terms of seconds and
|
||||
* fractional seconds.
|
||||
* A type code representing the generic SQL type {@code INTERVAL SECOND}
|
||||
* for a temporal duration given terms of seconds and fractional seconds.
|
||||
*/
|
||||
public static final int INTERVAL_SECOND = 3100;
|
||||
|
||||
// Geometry types
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code GEOMETRY}.
|
||||
* A type code representing the generic SQL type {@code GEOMETRY}.
|
||||
*/
|
||||
public static final int GEOMETRY = 3200;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code POINT}.
|
||||
* A type code representing the generic SQL type {@code POINT}.
|
||||
*/
|
||||
public static final int POINT = 3201;
|
||||
|
||||
/**
|
||||
* The constant in the Java programming language, sometimes referred to
|
||||
* as a type code, that identifies the generic SQL type {@code GEOGRAPHY}.
|
||||
* A type code representing the generic SQL type {@code GEOGRAPHY}.
|
||||
*
|
||||
* @since 6.0.1
|
||||
*/
|
||||
|
@ -464,10 +412,10 @@ public class SqlTypes {
|
|||
/**
|
||||
* Does the given JDBC type code represent some sort of
|
||||
* numeric type?
|
||||
* @param sqlType a JDBC type code from {@link Types}
|
||||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isNumericType(int sqlType) {
|
||||
switch (sqlType) {
|
||||
public static boolean isNumericType(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case Types.BIT:
|
||||
case Types.SMALLINT:
|
||||
case Types.TINYINT:
|
||||
|
@ -487,10 +435,10 @@ public class SqlTypes {
|
|||
/**
|
||||
* Does the given JDBC type code represent some sort of
|
||||
* character string type?
|
||||
* @param sqlType a JDBC type code from {@link Types}
|
||||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isCharacterOrClobType(int sqlType) {
|
||||
switch (sqlType) {
|
||||
public static boolean isCharacterOrClobType(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case Types.CHAR:
|
||||
case Types.VARCHAR:
|
||||
case Types.LONGVARCHAR:
|
||||
|
@ -508,10 +456,10 @@ public class SqlTypes {
|
|||
/**
|
||||
* Does the given JDBC type code represent some sort of
|
||||
* character string type?
|
||||
* @param sqlType a JDBC type code from {@link Types}
|
||||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isCharacterType(int sqlType) {
|
||||
switch (sqlType) {
|
||||
public static boolean isCharacterType(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case Types.CHAR:
|
||||
case Types.VARCHAR:
|
||||
case Types.LONGVARCHAR:
|
||||
|
@ -527,10 +475,10 @@ public class SqlTypes {
|
|||
/**
|
||||
* Does the given JDBC type code represent some sort of
|
||||
* variable-length character string type?
|
||||
* @param sqlType a JDBC type code from {@link Types}
|
||||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isVarcharType(int sqlType) {
|
||||
switch (sqlType) {
|
||||
public static boolean isVarcharType(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case Types.VARCHAR:
|
||||
case Types.LONGVARCHAR:
|
||||
case Types.NVARCHAR:
|
||||
|
@ -544,10 +492,10 @@ public class SqlTypes {
|
|||
/**
|
||||
* Does the given JDBC type code represent some sort of
|
||||
* variable-length binary string type?
|
||||
* @param sqlType a JDBC type code from {@link Types}
|
||||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isVarbinaryType(int sqlType) {
|
||||
switch (sqlType) {
|
||||
public static boolean isVarbinaryType(int typeCode) {
|
||||
switch (typeCode) {
|
||||
case Types.VARBINARY:
|
||||
case Types.LONGVARBINARY:
|
||||
return true;
|
||||
|
@ -568,8 +516,9 @@ public class SqlTypes {
|
|||
case Types.LONGVARBINARY:
|
||||
case Types.BLOB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -577,8 +526,13 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isNumericOrDecimal(int typeCode) {
|
||||
return typeCode == NUMERIC
|
||||
|| typeCode == DECIMAL;
|
||||
switch ( typeCode ) {
|
||||
case NUMERIC:
|
||||
case DECIMAL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -586,9 +540,14 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isFloatOrRealOrDouble(int typeCode) {
|
||||
return typeCode == FLOAT
|
||||
|| typeCode == REAL
|
||||
|| typeCode == DOUBLE;
|
||||
switch ( typeCode ) {
|
||||
case FLOAT:
|
||||
case REAL:
|
||||
case DOUBLE:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -596,10 +555,15 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isIntegral(int typeCode) {
|
||||
return typeCode == INTEGER
|
||||
|| typeCode == BIGINT
|
||||
|| typeCode == SMALLINT
|
||||
|| typeCode == TINYINT;
|
||||
switch ( typeCode ) {
|
||||
case INTEGER:
|
||||
case BIGINT:
|
||||
case SMALLINT:
|
||||
case TINYINT:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -607,11 +571,16 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean isTemporalType(int typeCode) {
|
||||
return typeCode == DATE
|
||||
|| typeCode == TIME
|
||||
|| typeCode == TIMESTAMP
|
||||
|| typeCode == TIMESTAMP_WITH_TIMEZONE
|
||||
|| typeCode == TIMESTAMP_UTC;
|
||||
switch ( typeCode ) {
|
||||
case DATE:
|
||||
case TIME:
|
||||
case TIMESTAMP:
|
||||
case TIMESTAMP_WITH_TIMEZONE:
|
||||
case TIMESTAMP_UTC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -626,10 +595,15 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean hasDatePart(int typeCode) {
|
||||
return typeCode == DATE
|
||||
|| typeCode == TIMESTAMP
|
||||
|| typeCode == TIMESTAMP_WITH_TIMEZONE
|
||||
|| typeCode == TIMESTAMP_UTC;
|
||||
switch ( typeCode ) {
|
||||
case DATE:
|
||||
case TIMESTAMP:
|
||||
case TIMESTAMP_WITH_TIMEZONE:
|
||||
case TIMESTAMP_UTC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -637,9 +611,14 @@ public class SqlTypes {
|
|||
* @param typeCode a JDBC type code from {@link Types}
|
||||
*/
|
||||
public static boolean hasTimePart(int typeCode) {
|
||||
return typeCode == TIME
|
||||
|| typeCode == TIMESTAMP
|
||||
|| typeCode == TIMESTAMP_WITH_TIMEZONE
|
||||
|| typeCode == TIMESTAMP_UTC;
|
||||
switch ( typeCode ) {
|
||||
case TIME:
|
||||
case TIMESTAMP:
|
||||
case TIMESTAMP_WITH_TIMEZONE:
|
||||
case TIMESTAMP_UTC:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
*/
|
||||
package org.hibernate.type.descriptor.jdbc;
|
||||
|
||||
import java.sql.Types;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.TemporalType;
|
||||
|
||||
import org.hibernate.TimeZoneStorageStrategy;
|
||||
import org.hibernate.type.SqlTypes;
|
||||
import org.hibernate.type.descriptor.java.BasicJavaType;
|
||||
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
|
|
@ -19,7 +19,8 @@ import org.hibernate.type.spi.TypeConfiguration;
|
|||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* Basically a map from JDBC type code (int) -> {@link JdbcType}
|
||||
* A registry mapping {@link org.hibernate.type.SqlTypes JDBC type codes}
|
||||
* to implementations of the {@link JdbcType} interface.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
* @author Andrea Boriero
|
||||
|
|
Loading…
Reference in New Issue