Package org.hibernate.usertype
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 an object from the cacheable representation.TdeepCopy(T value)Return a deep copy of the persistent state, stopping at entities and at collections.Serializabledisassemble(T value)Transform the object into its cacheable representation.booleanequals(T x, T y)Compare two instances of the class mapped by this type for persistence "equality".BasicJavaType<T>getJavaType()JdbcTypegetJdbcType(TypeConfiguration typeConfiguration)ValueBinder<Object>getJdbcValueBinder()ValueExtractor<Object>getJdbcValueExtractor()MutabilityPlan<T>getMutabilityPlan()intgetSqlType()Return the SQL type code for the column mapped by this type.BasicValueConverter<T,Object>getValueConverter()Returns the converter that this user type uses for transforming from the domain type, to the relational type, ornullif there is no conversion.inthashCode(T x)Get a hashcode for the instance, consistent with persistence "equality"booleanisMutable()Are objects of this type mutable?TnullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner)Retrieve an instance of the mapped class from a JDBC resultset.voidnullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session)Write an instance of the mapped class to a prepared statement.Treplace(T original, T target, Object owner)During merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging.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
-
-
-
-
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)
- 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 user 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 asJdbcMapping.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:UserTypeReturn the SQL type code for the column mapped by this type. The codes are generally defined onorg.hibernate.type.SqlTypes, but could be database-specific codes- 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) throws HibernateException
Description copied from interface:UserTypeCompare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.- Specified by:
equalsin interfaceUserType<T>- Throws:
HibernateException
-
hashCode
public int hashCode(T x) throws HibernateException
Description copied from interface:UserTypeGet a hashcode for the instance, consistent with persistence "equality"- Specified by:
hashCodein interfaceUserType<T>- Throws:
HibernateException
-
nullSafeGet
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException
Description copied from interface:UserTypeRetrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.- Specified by:
nullSafeGetin interfaceUserType<T>- Throws:
SQLException
-
nullSafeSet
public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) throws SQLException
Description copied from interface:UserTypeWrite an instance of the mapped class to a prepared statement. Implementors should handle possibility of null values. A multi-column type should be written to parameters starting fromindex.- Specified by:
nullSafeSetin interfaceUserType<T>- Throws:
SQLException
-
deepCopy
public T deepCopy(T value) throws HibernateException
Description copied from interface:UserTypeReturn a deep copy of the persistent state, stopping at entities and at collections. It is not necessary to copy immutable objects, or null values, in which case it is safe to simply return the argument.- Specified by:
deepCopyin interfaceUserType<T>- Parameters:
value- the object to be cloned, which may be null- Returns:
- Object a copy
- Throws:
HibernateException
-
isMutable
public boolean isMutable()
Description copied from interface:UserTypeAre objects of this type mutable?
-
disassemble
public Serializable disassemble(T value) throws HibernateException
Description copied from interface:UserTypeTransform the object into its cacheable representation. At the very least this method should perform a deep copy if the type is mutable. That may not be enough for some implementations, however; for example, associations must be cached as identifier values. (optional operation)- Specified by:
disassemblein interfaceUserType<T>- Parameters:
value- the object to be cached- Returns:
- a cacheable representation of the object
- Throws:
HibernateException
-
assemble
public T assemble(Serializable cached, Object owner) throws HibernateException
Description copied from interface:UserTypeReconstruct an object from the cacheable representation. At the very least this method should perform a deep copy if the type is mutable. (optional operation)- 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
-
replace
public T replace(T original, T target, Object owner) throws HibernateException
Description copied from interface:UserTypeDuring merge, replace the existing (target) value in the entity we are merging to with a new (original) value from the detached entity we are merging. For immutable objects, or null values, it is safe to simply return the first parameter. For mutable objects, it is safe to return a copy of the first parameter. For objects with component values, it might make sense to recursively replace component values.- Specified by:
replacein interfaceUserType<T>- Parameters:
original- the value from the detached entity being mergedtarget- the value in the managed entity- Returns:
- the value to be merged
- Throws:
HibernateException
-
-