Interface JdbcType
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
AdjustableJdbcType
,AggregateJdbcType
,JavaTimeJdbcType
,SqlTypedJdbcType
,StructJdbcType
- All Known Implementing Classes:
AbstractCastingPostGISJdbcType
,AbstractHANADialect.HANABlobType
,AbstractJavaTimeJdbcType
,AbstractPostGISJdbcType
,AbstractPostgreSQLJsonPGObjectType
,AbstractPostgreSQLStructJdbcType
,AbstractSqlServerGISType
,ArrayJdbcType
,BigIntJdbcType
,BinaryJdbcType
,BlobJdbcType
,BooleanJdbcType
,CharJdbcType
,ClobJdbcType
,DateJdbcType
,DB2GeometryType
,DB2StructJdbcType
,DecimalJdbcType
,DelayedStructJdbcType
,DoubleJdbcType
,DurationJdbcType
,EnumJdbcType
,FloatJdbcType
,H2DurationIntervalSecondJdbcType
,H2FormatJsonJdbcType
,H2GISGeometryType
,H2JsonJdbcType
,HANAGeometryType
,HANAPointType
,InstantAsTimestampJdbcType
,InstantAsTimestampWithTimeZoneJdbcType
,InstantJdbcType
,IntegerJdbcType
,JsonAsStringJdbcType
,JsonJdbcType
,LocalDateJdbcType
,LocalDateTimeJdbcType
,LocalTimeJdbcType
,LongNVarcharJdbcType
,LongVarbinaryJdbcType
,LongVarcharJdbcType
,MySQLCastingJsonJdbcType
,MySQLEnumJdbcType
,MySQLGeometryJdbcType
,NCharJdbcType
,NClobJdbcType
,NullJdbcType
,NumericJdbcType
,NVarcharJdbcType
,ObjectJdbcType
,ObjectNullAsBinaryTypeJdbcType
,ObjectNullAsNullTypeJdbcType
,ObjectNullResolvingJdbcType
,OffsetDateTimeJdbcType
,OffsetTimeJdbcType
,OracleArrayJdbcType
,OracleBaseStructJdbcType
,OracleBooleanJdbcType
,OracleEnumJdbcType
,OracleJsonBlobJdbcType
,OracleJsonJdbcType
,OracleNestedTableJdbcType
,OracleOrdinalEnumJdbcType
,OracleReflectionStructJdbcType
,OracleStructJdbcType
,OracleXmlJdbcType
,OrdinalEnumJdbcType
,PGCastingGeographyJdbcType
,PGCastingGeometryJdbcType
,PGGeographyJdbcType
,PGGeometryJdbcType
,PostgreSQLArrayJdbcType
,PostgreSQLCastingInetJdbcType
,PostgreSQLCastingIntervalSecondJdbcType
,PostgreSQLCastingJsonJdbcType
,PostgreSQLEnumJdbcType
,PostgreSQLInetJdbcType
,PostgreSQLIntervalSecondJdbcType
,PostgreSQLJsonPGObjectJsonbType
,PostgreSQLJsonPGObjectJsonType
,PostgreSQLOrdinalEnumJdbcType
,PostgreSQLStructCastingJdbcType
,PostgreSQLStructPGObjectJdbcType
,PostgreSQLUUIDJdbcType
,RealJdbcType
,RowIdJdbcType
,SDOGeometryType
,SmallIntJdbcType
,SqlServerGeographyType
,SqlServerGeometryType
,StructJdbcType
,TimeAsTimestampWithTimeZoneJdbcType
,TimeJdbcType
,TimestampJdbcType
,TimestampUtcAsInstantJdbcType
,TimestampUtcAsJdbcTimestampJdbcType
,TimestampUtcAsOffsetDateTimeJdbcType
,TimestampWithTimeZoneJdbcType
,TimeUtcAsJdbcTimeJdbcType
,TimeUtcAsOffsetTimeJdbcType
,TimeWithTimeZoneJdbcType
,TinyIntAsSmallIntJdbcType
,TinyIntJdbcType
,UserTypeSqlTypeAdapter
,UUIDJdbcType
,VarbinaryJdbcType
,VarcharJdbcType
,VarcharUUIDJdbcType
,XmlAsStringJdbcType
,XmlJdbcType
,ZonedDateTimeJdbcType
JdbcType
is
always coupled with a JavaType
to describe the typing aspects of an
attribute mapping from Java to JDBC.
An instance of this type need not correspond directly to a SQL column type on
a particular database. Rather, a JdbcType
defines how values are read
from and written to JDBC. Therefore, implementations of this interface map more
directly to the JDBC type codes defined by Types
and SqlTypes
.
Every JdbcType
has a ValueBinder
and a ValueExtractor
which, respectively, do the hard work of writing values to parameters of a
JDBC PreparedStatement
, and reading values from the columns
of a JDBC ResultSet
.
The JDBC type code ultimately determines, in collaboration with the SQL dialect, the SQL column type generated by Hibernate's schema export tool.
A JDBC type may be selected when mapping an entity attribute using the
JdbcType
annotation, or, indirectly, using
the JdbcTypeCode
annotation.
Custom implementations should be registered with the
JdbcTypeRegistry
at startup.
The built-in implementations are registered automatically.
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
addAuxiliaryDatabaseObjects
(JavaType<?> javaType, Size columnSize, Database database, JdbcTypeIndicators context) default void
addAuxiliaryDatabaseObjects
(JavaType<?> javaType, Size columnSize, Database database, TypeConfiguration typeConfiguration) Deprecated, for removal: This API element is subject to removal in a future version.default void
appendWriteExpression
(String writeExpression, SqlAppender appender, Dialect dialect) Append the write expression wrapped in a way to be able to write values with this JdbcType's ValueBinder.<X> ValueBinder<X>
Obtain a binder object capable of binding values of the given Java type to parameters of a JDBCPreparedStatement
.default CastType
static CastType
getCastType
(int typeCode) default String
getCheckCondition
(String columnName, JavaType<?> javaType, BasicValueConverter<?, ?> converter, Dialect dialect) The check constraint that should be added to the column definition in generated DDL.default int
A JDBC type code that identifies the SQL column type to be used for schema generation.default int
A JDBC type code that identifies the SQL column type.default String
getExtraCreateTableInfo
(JavaType<?> javaType, String columnName, String tableName, Database database) <X> ValueExtractor<X>
getExtractor
(JavaType<X> javaType) default String
A "friendly" name for use in loggingdefault <T> JdbcLiteralFormatter<T>
getJdbcLiteralFormatter
(JavaType<T> javaType) default <T> JavaType<T>
getJdbcRecommendedJavaTypeMapping
(Integer precision, Integer scale, TypeConfiguration typeConfiguration) int
The JDBC type code used when interacting with JDBC APIs.default Class<?>
getPreferredJavaTypeClass
(WrapperOptions options) The Java type class that is preferred by the binder or null.default boolean
default boolean
default boolean
isArray()
static boolean
isArray
(int jdbcTypeCode) default boolean
isBinary()
default boolean
default boolean
default boolean
default boolean
default boolean
isFloat()
default boolean
default boolean
default boolean
isLob()
static boolean
isLob
(int jdbcTypeCode) default boolean
static boolean
isLobOrLong
(int jdbcTypeCode) default boolean
static boolean
isNationalized
(int jdbcTypeCode) default boolean
isNumber()
default boolean
default boolean
default boolean
isString()
default boolean
default boolean
default boolean
default void
registerOutParameter
(CallableStatement callableStatement, int index) default void
registerOutParameter
(CallableStatement callableStatement, String name) default Expression
wrapTopLevelSelectionExpression
(Expression expression) Wraps the top level selection expression to be able to read values with this JdbcType's ValueExtractor.default String
wrapWriteExpression
(String writeExpression, Dialect dialect) Wraps the write expression to be able to write values with this JdbcType's ValueBinder.
-
Method Details
-
getFriendlyName
A "friendly" name for use in logging -
getJdbcTypeCode
int getJdbcTypeCode()The JDBC type code used when interacting with JDBC APIs.For example, it's used when calling
PreparedStatement.setNull(int, int)
.- Returns:
- a JDBC type code
-
getDefaultSqlTypeCode
default int getDefaultSqlTypeCode()A JDBC type code that identifies the SQL column type.This value might be different from
getDdlTypeCode()
if the actual type e.g. JSON is emulated through a type like CLOB.- Returns:
- a JDBC type code
-
getDdlTypeCode
default int getDdlTypeCode()A JDBC type code that identifies the SQL column type to be used for schema generation.This value is passed to
DdlTypeRegistry.getTypeName(int, Size, Type)
to obtain the SQL column type.- Returns:
- a JDBC type code
- Since:
- 6.2
-
getJdbcRecommendedJavaTypeMapping
default <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(Integer precision, Integer scale, TypeConfiguration typeConfiguration) -
getJdbcLiteralFormatter
-
getBinder
Obtain a binder object capable of binding values of the given Java type to parameters of a JDBCPreparedStatement
.- Parameters:
javaType
- The descriptor describing the types of Java values to be bound- Returns:
- The appropriate binder.
-
getExtractor
Obtain an extractor object capable of extracting values of the given Java type from a JDBCResultSet
.- Parameters:
javaType
- The descriptor describing the types of Java values to be extracted- Returns:
- The appropriate extractor
-
getPreferredJavaTypeClass
The Java type class that is preferred by the binder or null. -
getCheckCondition
default String getCheckCondition(String columnName, JavaType<?> javaType, BasicValueConverter<?, ?> converter, Dialect dialect) The check constraint that should be added to the column definition in generated DDL. -
wrapTopLevelSelectionExpression
Wraps the top level selection expression to be able to read values with this JdbcType's ValueExtractor.- Since:
- 6.2
-
wrapWriteExpression
Wraps the write expression to be able to write values with this JdbcType's ValueBinder.- Since:
- 6.2
-
appendWriteExpression
@Incubating default void appendWriteExpression(String writeExpression, SqlAppender appender, Dialect dialect) Append the write expression wrapped in a way to be able to write values with this JdbcType's ValueBinder.- Since:
- 6.2
-
isInteger
default boolean isInteger() -
isFloat
default boolean isFloat() -
isDecimal
default boolean isDecimal() -
isNumber
default boolean isNumber() -
isBinary
default boolean isBinary() -
isString
default boolean isString() -
isStringLike
default boolean isStringLike() -
isTemporal
default boolean isTemporal() -
isLob
default boolean isLob() -
isLob
static boolean isLob(int jdbcTypeCode) -
isLobOrLong
default boolean isLobOrLong() -
isLobOrLong
static boolean isLobOrLong(int jdbcTypeCode) -
isNationalized
default boolean isNationalized() -
isNationalized
static boolean isNationalized(int jdbcTypeCode) -
isInterval
default boolean isInterval() -
isDuration
default boolean isDuration() -
isArray
default boolean isArray() -
isArray
static boolean isArray(int jdbcTypeCode) -
getCastType
-
getCastType
-
registerOutParameter
default void registerOutParameter(CallableStatement callableStatement, String name) throws SQLException - Throws:
SQLException
- Since:
- 6.2
-
registerOutParameter
default void registerOutParameter(CallableStatement callableStatement, int index) throws SQLException - Throws:
SQLException
- Since:
- 6.2
-
addAuxiliaryDatabaseObjects
@Incubating @Deprecated(forRemoval=true) default void addAuxiliaryDatabaseObjects(JavaType<?> javaType, Size columnSize, Database database, TypeConfiguration typeConfiguration) Deprecated, for removal: This API element is subject to removal in a future version. -
addAuxiliaryDatabaseObjects
@Incubating default void addAuxiliaryDatabaseObjects(JavaType<?> javaType, Size columnSize, Database database, JdbcTypeIndicators context) - Since:
- 6.5
-
getExtraCreateTableInfo
-
isComparable
-
hasDatePart
-
hasTimePart
-
isStringLikeExcludingClob
-
isSpatial
-
isBoolean
-
isSmallInteger
-
addAuxiliaryDatabaseObjects(JavaType, Size, Database, JdbcTypeIndicators)
instead