Class StaticUserTypeSupport<T>
- java.lang.Object
- org.hibernate.usertype.StaticUserTypeSupport<T>
Constructor Summary
Constructors Constructor Description StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType)StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,BasicValueConverter<T,Object> valueConverter)StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,MutabilityPlan<T> mutabilityPlan)StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,MutabilityPlan<T> mutabilityPlan,BasicValueConverter<T,Object> valueConverter)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tassemble(Serializable cached,Object owner)Reconstruct a value from its destructured representation, during the process of reading the properties of an entity from thesecond-level cache.TdeepCopy(T value)Return a clone of the given instance of the Java class mapped by this custom type.Serializabledisassemble(T value)Transform the given value into a destructured representation, suitable for storage in thesecond-level cache.booleanequals(T x,T y)Compare two instances of the Java class mapped by this custom type for persistence "equality", that is, equality of their persistent state.BasicJavaType<T>getJavaType()JdbcTypegetJdbcType(TypeConfiguration typeConfiguration)A mappedJdbcType.ValueBinder<Object>getJdbcValueBinder()ValueExtractor<Object>getJdbcValueExtractor()MutabilityPlan<T>getMutabilityPlan()intgetSqlType()The JDBC/SQL type code for the database column mapped by this custom type.BasicValueConverter<T,Object>getValueConverter()Returns the converter that this custom type uses for transforming from the domain type to the relational type, ornullif there is no conversion.inthashCode(T x)Get a hash code for the given instance of the Java class mapped by this custom type, consistent with the definition ofpersistence "equality" for this custom type.booleanisMutable()Are instances of the Java class mapped by this custom type mutable or immutable?TnullSafeGet(ResultSet rs, int position,SharedSessionContractImplementor session,Object owner)Read an instance of the Java class mapped by this custom type from the given JDBCResultSet.voidnullSafeSet(PreparedStatement st,T value, int index,SharedSessionContractImplementor session)Write an instance of the Java class mapped by this custom type to the given JDBCPreparedStatement.Class<T>returnedClass()The class returned bynullSafeGet().Methods inherited from class java.lang.Object
clone,equals,finalize,getClass,hashCode,notify,notifyAll,toString,wait,wait,wait
Methods inherited from interface org.hibernate.usertype.UserType
getDefaultSqlLength,getDefaultSqlPrecision,getDefaultSqlScale,replace
Constructor Detail
StaticUserTypeSupport
public StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType)
StaticUserTypeSupport
public StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,MutabilityPlan<T> mutabilityPlan)
StaticUserTypeSupport
public StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,BasicValueConverter<T,Object> valueConverter)
StaticUserTypeSupport
public StaticUserTypeSupport(BasicJavaType<T> javaType,JdbcType jdbcType,MutabilityPlan<T> mutabilityPlan,BasicValueConverter<T,Object> valueConverter)
Method Detail
getJavaType
public BasicJavaType<T> getJavaType()
getJdbcType
public JdbcType getJdbcType(TypeConfiguration typeConfiguration)
Description copied from interface:UserType- Specified by:
getJdbcTypein interfaceUserType<T>
getMutabilityPlan
public MutabilityPlan<T> getMutabilityPlan()
getValueConverter
public BasicValueConverter<T,Object> getValueConverter()
Description copied from interface:UserTypeReturns the converter that this custom type uses for transforming from the domain type to the relational type, ornullif there is no conversion.Note that it is vital to provide a converter if a column should be mapped to multiple domain types, as Hibernate will only select a column once and materialize values as instances of the Java type given by
JdbcMapping.getJdbcJavaType(). Support for multiple domain type representations works by converting objects of that type to the domain type.- Specified by:
getValueConverterin interfaceUserType<T>
getJdbcValueExtractor
public ValueExtractor<Object> getJdbcValueExtractor()
getJdbcValueBinder
public ValueBinder<Object> getJdbcValueBinder()
getSqlType
public int getSqlType()
Description copied from interface:UserTypeThe JDBC/SQL type code for the database column mapped by this custom type.The type code is usually one of the standard type codes declared by
SqlTypes, but it could be a database-specific code.- Specified by:
getSqlTypein interfaceUserType<T>- See Also:
SqlTypes
returnedClass
public Class<T> returnedClass()
Description copied from interface:UserTypeThe class returned bynullSafeGet().- Specified by:
returnedClassin interfaceUserType<T>- Returns:
- Class
equals
public boolean equals(T x,T y) throwsHibernateException
Description copied from interface:UserTypeCompare two instances of the Java class mapped by this custom type for persistence "equality", that is, equality of their persistent state.- Specified by:
equalsin interfaceUserType<T>- Throws:
HibernateException
hashCode
public int hashCode(T x) throwsHibernateException
Description copied from interface:UserTypeGet a hash code for the given instance of the Java class mapped by this custom type, consistent with the definition ofpersistence "equality" for this custom type.- Specified by:
hashCodein interfaceUserType<T>- Throws:
HibernateException
nullSafeGet
public T nullSafeGet(ResultSet rs, int position,SharedSessionContractImplementor session,Object owner) throwsSQLException
Description copied from interface:UserTypeRead an instance of the Java class mapped by this custom type from the given JDBCResultSet. Implementors must handle null column values.- Specified by:
nullSafeGetin interfaceUserType<T>owner- in Hibernate 6, this is always null- Throws:
SQLException
nullSafeSet
public void nullSafeSet(PreparedStatement st,T value, int index,SharedSessionContractImplementor session) throwsSQLException
Description copied from interface:UserTypeWrite an instance of the Java class mapped by this custom type to the given JDBCPreparedStatement. Implementors must handle null values of the Java class. A multi-column type should be written to parameters starting fromindex.- Specified by:
nullSafeSetin interfaceUserType<T>- Throws:
SQLException
deepCopy
public T deepCopy(T value) throwsHibernateException
Description copied from interface:UserTypeReturn a clone of the given instance of the Java class mapped by this custom type.- It's not necessary to clone immutable objects. If the Java class mapped by this custom type is an immutable class, this method may safely just return its argument.
- For mutable objects, it's necessary to deep copy persistent state, stopping at associations to other entities, and at persistent collections.
- If the argument is a reference to an entity, just return the argument.
- Finally, if the argument is null, just return null.
- Specified by:
deepCopyin interfaceUserType<T>- Parameters:
value- the object to be cloned, which may be null- Returns:
- a clone
- Throws:
HibernateException
isMutable
public boolean isMutable()
Description copied from interface:UserTypeAre instances of the Java class mapped by this custom type mutable or immutable?
disassemble
public Serializable disassemble(T value) throwsHibernateException
Description copied from interface:UserTypeTransform the given value into a destructured representation, suitable for storage in thesecond-level cache. This method is called only during the process of writing the properties of an entity to the second-level cache.If the value is mutable then, at the very least, this method should perform a deep copy. That may not be enough for some types, however. For example, associations must be cached as identifier values.
This is an optional operation, but, if left unimplemented, this type will not be cacheable in the second-level cache.
- Specified by:
disassemblein interfaceUserType<T>- Parameters:
value- the object to be cached- Returns:
- a cacheable representation of the object
- Throws:
HibernateException- See Also:
Cache
assemble
public T assemble(Serializable cached,Object owner) throwsHibernateException
Description copied from interface:UserTypeReconstruct a value from its destructured representation, during the process of reading the properties of an entity from thesecond-level cache.If the value is mutable then, at the very least, this method should perform a deep copy. That may not be enough for some types, however. For example, associations must be cached as identifier values.
This is an optional operation, but, if left unimplemented, this type will not be cacheable in the second-level cache.
- Specified by:
assemblein interfaceUserType<T>- Parameters:
cached- the object to be cachedowner- the owner of the cached object- Returns:
- a reconstructed object from the cacheable representation
- Throws:
HibernateException- See Also:
Cache