Package org.hibernate.dialect
Class DB2StructJdbcType
- java.lang.Object
-
- org.hibernate.dialect.DB2StructJdbcType
-
- All Implemented Interfaces:
Serializable
,AggregateJdbcType
,JdbcType
,SqlTypedJdbcType
,StructJdbcType
public class DB2StructJdbcType extends Object implements StructJdbcType
DB2 supports UDTs but not in JDBC, so there is a feature called "transforms", which allows to specify an automatic translation from one data type to another. To support UDTs, we require that a transform exists for the UDT that serializes from SQL to XML and deserializes to SQL from UDT. This means that from the JDBC perspective, this is an XML type, but the database models it internally as UDT.The
DB2AggregateSupport
generates the functions and transforms for this process automatically, but note that all of this is only used for functions and native queries. By default, we select individual struct parts to avoid the encoding/decoding.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static DB2StructJdbcType
INSTANCE
-
Constructor Summary
Constructors Constructor Description DB2StructJdbcType(EmbeddableMappingType embeddableMappingType, String structTypeName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SQLXML
createJdbcValue(Object value, WrapperOptions options)
Object[]
extractJdbcValues(Object rawJdbcValue, WrapperOptions options)
<X> ValueBinder<X>
getBinder(JavaType<X> javaType)
Obtain a binder object capable of binding values of the given Java type to parameters of a JDBCPreparedStatement
.int
getDefaultSqlTypeCode()
A JDBC type code that identifies the SQL column type.EmbeddableMappingType
getEmbeddableMappingType()
<X> ValueExtractor<X>
getExtractor(JavaType<X> javaType)
<T> JavaType<T>
getJdbcRecommendedJavaTypeMapping(Integer precision, Integer scale, TypeConfiguration typeConfiguration)
int
getJdbcTypeCode()
The JDBC type code used when interacting with JDBC APIs.String
getStructTypeName()
AggregateJdbcType
resolveAggregateJdbcType(EmbeddableMappingType mappingType, String sqlType, RuntimeModelCreationContext creationContext)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.type.descriptor.jdbc.JdbcType
addAuxiliaryDatabaseObjects, addAuxiliaryDatabaseObjects, appendWriteExpression, getCastType, getCheckCondition, getDdlTypeCode, getExtraCreateTableInfo, getFriendlyName, getJdbcLiteralFormatter, getPreferredJavaTypeClass, hasDatePart, hasTimePart, isArray, isBinary, isBoolean, isComparable, isDecimal, isDuration, isFloat, isInteger, isInterval, isLob, isLobOrLong, isNationalized, isNumber, isSmallInteger, isSpatial, isString, isStringLike, isStringLikeExcludingClob, isTemporal, registerOutParameter, registerOutParameter, wrapTopLevelSelectionExpression, wrapWriteExpression
-
Methods inherited from interface org.hibernate.type.descriptor.jdbc.StructJdbcType
getSqlTypeName
-
-
-
-
Field Detail
-
INSTANCE
public static final DB2StructJdbcType INSTANCE
-
-
Constructor Detail
-
DB2StructJdbcType
public DB2StructJdbcType(EmbeddableMappingType embeddableMappingType, String structTypeName)
-
-
Method Detail
-
getJdbcTypeCode
public int getJdbcTypeCode()
Description copied from interface:JdbcType
The JDBC type code used when interacting with JDBC APIs.For example, it's used when calling
PreparedStatement.setNull(int, int)
.- Specified by:
getJdbcTypeCode
in interfaceJdbcType
- Returns:
- a JDBC type code
-
getDefaultSqlTypeCode
public int getDefaultSqlTypeCode()
Description copied from interface:JdbcType
A JDBC type code that identifies the SQL column type.This value might be different from
JdbcType.getDdlTypeCode()
if the actual type e.g. JSON is emulated through a type like CLOB.- Specified by:
getDefaultSqlTypeCode
in interfaceJdbcType
- Returns:
- a JDBC type code
-
resolveAggregateJdbcType
public AggregateJdbcType resolveAggregateJdbcType(EmbeddableMappingType mappingType, String sqlType, RuntimeModelCreationContext creationContext)
- Specified by:
resolveAggregateJdbcType
in interfaceAggregateJdbcType
-
getEmbeddableMappingType
public EmbeddableMappingType getEmbeddableMappingType()
- Specified by:
getEmbeddableMappingType
in interfaceAggregateJdbcType
-
getStructTypeName
public String getStructTypeName()
- Specified by:
getStructTypeName
in interfaceStructJdbcType
-
getJdbcRecommendedJavaTypeMapping
public <T> JavaType<T> getJdbcRecommendedJavaTypeMapping(Integer precision, Integer scale, TypeConfiguration typeConfiguration)
- Specified by:
getJdbcRecommendedJavaTypeMapping
in interfaceJdbcType
-
getBinder
public <X> ValueBinder<X> getBinder(JavaType<X> javaType)
Description copied from interface:JdbcType
Obtain a binder object capable of binding values of the given Java type to parameters of a JDBCPreparedStatement
.
-
getExtractor
public <X> ValueExtractor<X> getExtractor(JavaType<X> javaType)
Description copied from interface:JdbcType
Obtain an extractor object capable of extracting values of the given Java type from a JDBCResultSet
.- Specified by:
getExtractor
in interfaceJdbcType
- Parameters:
javaType
- The descriptor describing the types of Java values to be extracted- Returns:
- The appropriate extractor
-
createJdbcValue
public SQLXML createJdbcValue(Object value, WrapperOptions options) throws SQLException
- Specified by:
createJdbcValue
in interfaceAggregateJdbcType
- Throws:
SQLException
-
extractJdbcValues
public Object[] extractJdbcValues(Object rawJdbcValue, WrapperOptions options) throws SQLException
- Specified by:
extractJdbcValues
in interfaceAggregateJdbcType
- Throws:
SQLException
-
-