接口 UserType
-
- 所有已知子接口:
EnhancedUserType,UserVersionType
- 所有已知实现类:
EnumType
public interface UserTypeThis interface should be implemented by user-defined "types". A "type" class is not the actual property type - it is a class that knows how to serialize instances of another class to and from JDBC.
This interface- abstracts user code from future changes to the Type interface,
- simplifies the implementation of custom types and
- hides certain "internal" interfaces from user code.
Implementors must be immutable and must declare a public default constructor.
The actual class mapped by a UserType may be just about anything.
CompositeUserType provides an extended version of this interface that is useful for more complex cases.
Alternatively, custom types could implement Type directly or extend one of the abstract classes in org.hibernate.type. This approach risks future incompatible changes to classes or interfaces in that package.- 作者:
- Gavin King
- 另请参阅:
for more complex cases,Type
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 Objectassemble(Serializable cached, Object owner)Reconstruct an object from the cacheable representation.ObjectdeepCopy(Object value)Return a deep copy of the persistent state, stopping at entities and at collections.Serializabledisassemble(Object value)Transform the object into its cacheable representation.booleanequals(Object x, Object y)Compare two instances of the class mapped by this type for persistence "equality".inthashCode(Object x)Get a hashcode for the instance, consistent with persistence "equality"booleanisMutable()Are objects of this type mutable?ObjectnullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner)Retrieve an instance of the mapped class from a JDBC resultset.voidnullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session)Write an instance of the mapped class to a prepared statement.Objectreplace(Object original, Object 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.ClassreturnedClass()The class returned by nullSafeGet().int[]sqlTypes()Return the SQL type codes for the columns mapped by this type.
-
-
-
方法详细资料
-
sqlTypes
int[] sqlTypes()
Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.- 返回:
- int[] the typecodes
- 另请参阅:
Types
-
returnedClass
Class returnedClass()
The class returned by nullSafeGet().- 返回:
- Class
-
equals
boolean equals(Object x, Object y) throws HibernateException
Compare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.- 参数:
x-y-- 返回:
- boolean
- 抛出:
HibernateException
-
hashCode
int hashCode(Object x) throws HibernateException
Get a hashcode for the instance, consistent with persistence "equality"
-
nullSafeGet
Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws HibernateException, SQLException
Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.- 参数:
rs- a JDBC result setnames- the column namessession-owner- the containing entity @return Object- 抛出:
HibernateExceptionSQLException
-
nullSafeSet
void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException
Write 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 from index.- 参数:
st- a JDBC prepared statementvalue- the object to writeindex- statement parameter indexsession-- 抛出:
HibernateExceptionSQLException
-
deepCopy
Object deepCopy(Object value) throws HibernateException
Return 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.- 参数:
value- the object to be cloned, which may be null- 返回:
- Object a copy
- 抛出:
HibernateException
-
isMutable
boolean isMutable()
Are objects of this type mutable?- 返回:
- boolean
-
disassemble
Serializable disassemble(Object value) throws HibernateException
Transform 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)- 参数:
value- the object to be cached- 返回:
- a cacheable representation of the object
- 抛出:
HibernateException
-
assemble
Object assemble(Serializable cached, Object owner) throws HibernateException
Reconstruct an object from the cacheable representation. At the very least this method should perform a deep copy if the type is mutable. (optional operation)- 参数:
cached- the object to be cachedowner- the owner of the cached object- 返回:
- a reconstructed object from the cacheable representation
- 抛出:
HibernateException
-
replace
Object replace(Object original, Object target, Object owner) throws HibernateException
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. 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.- 参数:
original- the value from the detached entity being mergedtarget- the value in the managed entity- 返回:
- the value to be merged
- 抛出:
HibernateException
-
-