类 EnumType<T extends Enum>
- java.lang.Object
-
- org.hibernate.type.EnumType<T>
-
- 所有已实现的接口:
Serializable,TypeConfigurationAware,DynamicParameterizedType,EnhancedUserType,LoggableUserType,ParameterizedType,UserType
public class EnumType<T extends Enum> extends Object implements EnhancedUserType, DynamicParameterizedType, LoggableUserType, TypeConfigurationAware, Serializable
Value type mapper for enumerations. Generally speaking, the proper configuration is picked up from the annotations associated with the mapped attribute. There are a few configuration parameters understood by this type mapper:- enumClass - Names the enumeration class.
-
useNamed - Should enum be mapped via name. Default is to map as ordinal. Used when
annotations are not used (otherwise
EnumTypeis used). - type - Identifies the JDBC type (via type code) to be used for the column.
- 作者:
- Emmanuel Bernard, Hardy Ferentschik, Steve Ebersole
- 另请参阅:
- 序列化表格
-
-
嵌套类概要
-
从接口继承的嵌套类/接口 org.hibernate.usertype.DynamicParameterizedType
DynamicParameterizedType.ParameterType
-
-
字段概要
字段 修饰符和类型 字段 说明 static StringENUMstatic StringNAMEDstatic StringTYPE-
从接口继承的字段 org.hibernate.usertype.DynamicParameterizedType
ACCESS_TYPE, ENTITY, IS_DYNAMIC, IS_PRIMARY_KEY, PARAMETER_TYPE, PROPERTY, RETURNED_CLASS, XPROPERTY
-
-
构造器概要
构造器 构造器 说明 EnumType()
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 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".ObjectfromXMLString(String xmlValue)Parse a string representation of this value, as it appears in an XML documentTypeConfigurationgetTypeConfiguration()inthashCode(Object x)Get a hashcode for the instance, consistent with persistence "equality"booleanisMutable()Are objects of this type mutable?booleanisOrdinal()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.StringobjectToSQLString(Object value)Return an SQL literal representation of the valueObjectreplace(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.Class<? extends Enum>returnedClass()The class returned by nullSafeGet().voidsetParameterValues(Properties parameters)Gets called by Hibernate to pass the configured type parameters to the implementation.voidsetTypeConfiguration(TypeConfiguration typeConfiguration)int[]sqlTypes()Return the SQL type codes for the columns mapped by this type.StringtoLoggableString(Object value, SessionFactoryImplementor factory)Generate a loggable string representation of the collection (value).StringtoXMLString(Object value)Return a string representation of this value, as it should appear in an XML document
-
-
-
方法详细资料
-
setParameterValues
public void setParameterValues(Properties parameters)
从接口复制的说明:ParameterizedTypeGets called by Hibernate to pass the configured type parameters to the implementation.- 指定者:
setParameterValues在接口中ParameterizedType
-
sqlTypes
public int[] sqlTypes()
从接口复制的说明:UserTypeReturn the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.
-
returnedClass
public Class<? extends Enum> returnedClass()
从接口复制的说明:UserTypeThe class returned by nullSafeGet().- 指定者:
returnedClass在接口中UserType- 返回:
- Class
-
equals
public boolean equals(Object x, Object y) throws HibernateException
从接口复制的说明:UserTypeCompare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.- 指定者:
equals在接口中UserType- 返回:
- boolean
- 抛出:
HibernateException
-
hashCode
public int hashCode(Object x) throws HibernateException
从接口复制的说明:UserTypeGet a hashcode for the instance, consistent with persistence "equality"- 指定者:
hashCode在接口中UserType- 抛出:
HibernateException
-
nullSafeGet
public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) throws SQLException
从接口复制的说明:UserTypeRetrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.- 指定者:
nullSafeGet在接口中UserType- 参数:
rs- a JDBC result setnames- the column namesowner- the containing entity @return Object- 抛出:
SQLException
-
nullSafeSet
public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException
从接口复制的说明: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 from index.- 指定者:
nullSafeSet在接口中UserType- 参数:
st- a JDBC prepared statementvalue- the object to writeindex- statement parameter index- 抛出:
HibernateExceptionSQLException
-
deepCopy
public Object deepCopy(Object value) throws HibernateException
从接口复制的说明: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.- 指定者:
deepCopy在接口中UserType- 参数:
value- the object to be cloned, which may be null- 返回:
- Object a copy
- 抛出:
HibernateException
-
isMutable
public boolean isMutable()
从接口复制的说明:UserTypeAre objects of this type mutable?
-
disassemble
public Serializable disassemble(Object value) throws HibernateException
从接口复制的说明: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)- 指定者:
disassemble在接口中UserType- 参数:
value- the object to be cached- 返回:
- a cacheable representation of the object
- 抛出:
HibernateException
-
assemble
public Object assemble(Serializable cached, Object owner) throws HibernateException
从接口复制的说明: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)- 指定者:
assemble在接口中UserType- 参数:
cached- the object to be cachedowner- the owner of the cached object- 返回:
- a reconstructed object from the cacheable representation
- 抛出:
HibernateException
-
replace
public Object replace(Object original, Object target, Object owner) throws HibernateException
从接口复制的说明: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.- 指定者:
replace在接口中UserType- 参数:
original- the value from the detached entity being mergedtarget- the value in the managed entity- 返回:
- the value to be merged
- 抛出:
HibernateException
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
- 指定者:
getTypeConfiguration在接口中TypeConfigurationAware
-
setTypeConfiguration
public void setTypeConfiguration(TypeConfiguration typeConfiguration)
- 指定者:
setTypeConfiguration在接口中TypeConfigurationAware
-
objectToSQLString
public String objectToSQLString(Object value)
从接口复制的说明:EnhancedUserTypeReturn an SQL literal representation of the value- 指定者:
objectToSQLString在接口中EnhancedUserType
-
toXMLString
public String toXMLString(Object value)
从接口复制的说明:EnhancedUserTypeReturn a string representation of this value, as it should appear in an XML document- 指定者:
toXMLString在接口中EnhancedUserType
-
fromXMLString
public Object fromXMLString(String xmlValue)
从接口复制的说明:EnhancedUserTypeParse a string representation of this value, as it appears in an XML document- 指定者:
fromXMLString在接口中EnhancedUserType
-
toLoggableString
public String toLoggableString(Object value, SessionFactoryImplementor factory)
从接口复制的说明:LoggableUserTypeGenerate a loggable string representation of the collection (value).- 指定者:
toLoggableString在接口中LoggableUserType- 参数:
value- The collection to be logged; guaranteed to be non-null and initialized.factory- The factory.- 返回:
- The loggable string representation.
-
isOrdinal
public boolean isOrdinal()
-
-