Class DbTimestampJavaTypeDescriptor<T>
- java.lang.Object
-
- org.hibernate.type.descriptor.java.DbTimestampJavaTypeDescriptor<T>
-
- All Implemented Interfaces:
Serializable
,BasicJavaType<T>
,JavaType<T>
,TemporalJavaTypeDescriptor<T>
,VersionJavaType<T>
public class DbTimestampJavaTypeDescriptor<T> extends Object implements VersionJavaType<T>, TemporalJavaTypeDescriptor<T>
Wrapper Java type descriptor for that uses the database timestamp as seed value for versions.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.type.descriptor.java.JavaType
JavaType.CoercionContext
-
-
Constructor Summary
Constructors Constructor Description DbTimestampJavaTypeDescriptor(TemporalJavaTypeDescriptor<T> delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
areEqual(T one, T another)
Determine if two instances are equal<X> T
coerce(X value, JavaType.CoercionContext coercionContext)
int
extractHashCode(T value)
Extract a proper hash code for this value.String
extractLoggableRepresentation(T value)
Extract a loggable representation of the value.T
fromString(CharSequence string)
String
getCheckCondition(String columnName, JdbcType sqlType, Dialect dialect)
The check constraint that should be added to the column definition in generated DDL.Comparator<T>
getComparator()
Retrieve the natural comparator for this type.long
getDefaultSqlLength(Dialect dialect, JdbcType jdbcType)
The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for exampleTypes.VARCHAR
.int
getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType)
The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for exampleTypes.DECIMAL
.int
getDefaultSqlScale(Dialect dialect, JdbcType jdbcType)
The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for exampleTypes.DECIMAL
.Type
getJavaType()
Get the Java type (Type) describedClass<T>
getJavaTypeClass()
Get the Java type (Class) describedlong
getLongSqlLength()
The default column length when this Java type is mapped to a column of typeTypes.LONGVARCHAR
orTypes.LONGVARBINARY
.MutabilityPlan<T>
getMutabilityPlan()
Retrieve the mutability plan for this Java type.jakarta.persistence.TemporalType
getPrecision()
The precision represented by this typeJdbcType
getRecommendedJdbcType(JdbcTypeDescriptorIndicators indicators)
Obtain the "recommended" SQL type descriptor for this Java type.T
next(T current, SharedSessionContractImplementor session)
Increment the version.<X> TemporalJavaTypeDescriptor<X>
resolveTypeForPrecision(jakarta.persistence.TemporalType precision, TypeConfiguration typeConfiguration)
Resolve the appropriate TemporalJavaTypeDescriptor for the given precision "relative" to this type.T
seed(SharedSessionContractImplementor session)
Generate an initial version.String
toString(T value)
<X> X
unwrap(T value, Class<X> type, WrapperOptions options)
Unwrap an instance of our handled Java type into the requested type.<X> T
wrap(X value, WrapperOptions options)
Wrap a value as our handled Java type.-
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.java.JavaType
getDefaultValue, getReplacement, isInstance, isWider
-
-
-
-
Constructor Detail
-
DbTimestampJavaTypeDescriptor
public DbTimestampJavaTypeDescriptor(TemporalJavaTypeDescriptor<T> delegate)
-
-
Method Detail
-
next
public T next(T current, SharedSessionContractImplementor session)
Description copied from interface:VersionJavaType
Increment the version.- Specified by:
next
in interfaceVersionJavaType<T>
- Parameters:
current
- the current versionsession
- The session from which this request originates.- Returns:
- an instance of the type
-
seed
public T seed(SharedSessionContractImplementor session)
Description copied from interface:VersionJavaType
Generate an initial version.- Specified by:
seed
in interfaceVersionJavaType<T>
- Parameters:
session
- The session from which this request originates.- Returns:
- an instance of the type
-
getRecommendedJdbcType
public JdbcType getRecommendedJdbcType(JdbcTypeDescriptorIndicators indicators)
Description copied from interface:JavaType
Obtain the "recommended" SQL type descriptor for this Java type. The recommended aspect comes from the JDBC spec (mostly).- Specified by:
getRecommendedJdbcType
in interfaceBasicJavaType<T>
- Specified by:
getRecommendedJdbcType
in interfaceJavaType<T>
- Parameters:
indicators
- Contextual information- Returns:
- The recommended SQL type descriptor
-
fromString
public T fromString(CharSequence string)
- Specified by:
fromString
in interfaceBasicJavaType<T>
- Specified by:
fromString
in interfaceJavaType<T>
-
getJavaType
public Type getJavaType()
Description copied from interface:JavaType
Get the Java type (Type) described- Specified by:
getJavaType
in interfaceJavaType<T>
- See Also:
JavaType.getJavaTypeClass()
-
getMutabilityPlan
public MutabilityPlan<T> getMutabilityPlan()
Description copied from interface:JavaType
Retrieve the mutability plan for this Java type.- Specified by:
getMutabilityPlan
in interfaceJavaType<T>
-
getDefaultSqlLength
public long getDefaultSqlLength(Dialect dialect, JdbcType jdbcType)
Description copied from interface:JavaType
The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for exampleTypes.VARCHAR
.- Specified by:
getDefaultSqlLength
in interfaceJavaType<T>
- Returns:
Size.DEFAULT_LENGTH
unless overridden
-
getLongSqlLength
public long getLongSqlLength()
Description copied from interface:JavaType
The default column length when this Java type is mapped to a column of typeTypes.LONGVARCHAR
orTypes.LONGVARBINARY
.- Specified by:
getLongSqlLength
in interfaceJavaType<T>
- Returns:
Size.LONG_LENGTH
unless overridden
-
getDefaultSqlPrecision
public int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType)
Description copied from interface:JavaType
The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for exampleTypes.DECIMAL
.- Specified by:
getDefaultSqlPrecision
in interfaceJavaType<T>
- Returns:
Size.DEFAULT_PRECISION
unless overridden
-
getDefaultSqlScale
public int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType)
Description copied from interface:JavaType
The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for exampleTypes.DECIMAL
.- Specified by:
getDefaultSqlScale
in interfaceJavaType<T>
- Returns:
Size.DEFAULT_SCALE
unless overridden
-
getComparator
public Comparator<T> getComparator()
Description copied from interface:JavaType
Retrieve the natural comparator for this type.- Specified by:
getComparator
in interfaceJavaType<T>
-
extractHashCode
public int extractHashCode(T value)
Description copied from interface:JavaType
Extract a proper hash code for this value.- Specified by:
extractHashCode
in interfaceJavaType<T>
- Parameters:
value
- The value for which to extract a hash code.- Returns:
- The extracted hash code.
-
areEqual
public boolean areEqual(T one, T another)
Description copied from interface:JavaType
Determine if two instances are equal
-
extractLoggableRepresentation
public String extractLoggableRepresentation(T value)
Description copied from interface:JavaType
Extract a loggable representation of the value.- Specified by:
extractLoggableRepresentation
in interfaceJavaType<T>
- Parameters:
value
- The value for which to extract a loggable representation.- Returns:
- The loggable representation
-
unwrap
public <X> X unwrap(T value, Class<X> type, WrapperOptions options)
Description copied from interface:JavaType
Unwrap an instance of our handled Java type into the requested type. As an example, if this is aJavaTypeDescriptor<Integer>
and we are asked to unwrap theInteger value
as aLong
we would return something likeLong.valueOf( value.longValue() )
. Intended use is duringPreparedStatement
binding.
-
wrap
public <X> T wrap(X value, WrapperOptions options)
Description copied from interface:JavaType
Wrap a value as our handled Java type. Intended use is duringResultSet
extraction.
-
coerce
public <X> T coerce(X value, JavaType.CoercionContext coercionContext)
-
getJavaTypeClass
public Class<T> getJavaTypeClass()
Description copied from interface:JavaType
Get the Java type (Class) described- Specified by:
getJavaTypeClass
in interfaceJavaType<T>
- See Also:
JavaType.getJavaType()
-
getCheckCondition
public String getCheckCondition(String columnName, JdbcType sqlType, Dialect dialect)
Description copied from interface:JavaType
The check constraint that should be added to the column definition in generated DDL.- Specified by:
getCheckCondition
in interfaceJavaType<T>
- Parameters:
columnName
- the name of the columnsqlType
- theJdbcType
of the mapped columndialect
- the SQLDialect
- Returns:
- a check constraint condition or null
-
getPrecision
public jakarta.persistence.TemporalType getPrecision()
Description copied from interface:TemporalJavaTypeDescriptor
The precision represented by this type- Specified by:
getPrecision
in interfaceTemporalJavaTypeDescriptor<T>
-
resolveTypeForPrecision
public <X> TemporalJavaTypeDescriptor<X> resolveTypeForPrecision(jakarta.persistence.TemporalType precision, TypeConfiguration typeConfiguration)
Description copied from interface:TemporalJavaTypeDescriptor
Resolve the appropriate TemporalJavaTypeDescriptor for the given precision "relative" to this type.- Specified by:
resolveTypeForPrecision
in interfaceTemporalJavaTypeDescriptor<T>
-
-