Class EnumType<T extends Enum<T>>
- java.lang.Object
-
- org.hibernate.type.EnumType<T>
-
- All Implemented Interfaces:
Serializable,TypeConfigurationAware,DynamicParameterizedType,EnhancedUserType<T>,LoggableUserType,ParameterizedType,UserType<T>
@Deprecated(since="6.2", forRemoval=true) public class EnumType<T extends Enum<T>> extends Object implements EnhancedUserType<T>, DynamicParameterizedType, LoggableUserType, TypeConfigurationAware, Serializable
Deprecated, for removal: This API element is subject to removal in a future version.UseConvertedBasicTypeinsteadValue type mapper for enumerations.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.hibernate.usertype.DynamicParameterizedType
DynamicParameterizedType.ParameterType
-
-
Field Summary
Fields Modifier and Type Field Description static StringENUMDeprecated, for removal: This API element is subject to removal in a future version.static StringNAMEDDeprecated, for removal: This API element is subject to removal in a future version.static StringTYPEDeprecated, for removal: This API element is subject to removal in a future version.-
Fields inherited from interface org.hibernate.usertype.DynamicParameterizedType
ACCESS_TYPE, ENTITY, IS_DYNAMIC, IS_PRIMARY_KEY, PARAMETER_TYPE, PROPERTY, RETURNED_CLASS, XPROPERTY
-
-
Constructor Summary
Constructors Constructor Description EnumType()Deprecated, for removal: This API element is subject to removal in a future version.EnumType(Class<T> enumClass, EnumValueConverter<T,?> enumValueConverter, TypeConfiguration typeConfiguration)Deprecated, for removal: This API element is subject to removal in a future version.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Tassemble(Serializable cached, Object owner)Deprecated, for removal: This API element is subject to removal in a future version.Reconstruct a value from its destructured representation, during the process of reading the properties of an entity from the second-level cache.TdeepCopy(T value)Deprecated, for removal: This API element is subject to removal in a future version.Return a clone of the given instance of the Java class mapped by this custom type.Serializabledisassemble(T value)Deprecated, for removal: This API element is subject to removal in a future version.Transform the given value into a destructured representation, suitable for storage in the second-level cache.booleanequals(T x, T y)Deprecated, for removal: This API element is subject to removal in a future version.Compare two instances of the Java class mapped by this custom type for persistence "equality", that is, equality of their persistent state.TfromStringValue(CharSequence sequence)Deprecated, for removal: This API element is subject to removal in a future version.Consume the given string representation back into this types java form.EnumValueConverter<T,?>getEnumValueConverter()Deprecated, for removal: This API element is subject to removal in a future version.JdbcTypegetJdbcType(TypeConfiguration typeConfiguration)Deprecated, for removal: This API element is subject to removal in a future version.A mappedJdbcType.intgetSqlType()Deprecated, for removal: This API element is subject to removal in a future version.The JDBC/SQL type code for the database column mapped by this custom type.TypeConfigurationgetTypeConfiguration()Deprecated, for removal: This API element is subject to removal in a future version.BasicValueConverter<T,Object>getValueConverter()Deprecated, for removal: This API element is subject to removal in a future version.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)Deprecated, for removal: This API element is subject to removal in a future version.Get a hash code for the given instance of the Java class mapped by this custom type, consistent with the definition of persistence "equality" for this custom type.booleanisMutable()Deprecated, for removal: This API element is subject to removal in a future version.Are instances of the Java class mapped by this custom type mutable or immutable?booleanisOrdinal()Deprecated, for removal: This API element is subject to removal in a future version.TnullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner)Deprecated, for removal: This API element is subject to removal in a future version.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)Deprecated, for removal: This API element is subject to removal in a future version.Write an instance of the Java class mapped by this custom type to the given JDBCPreparedStatement.Treplace(T original, T target, Object owner)Deprecated, for removal: This API element is subject to removal in a future version.During merge, replace the existing (target) value in the managed entity we are merging to with a new (original) value from the detached entity we are merging.Class<T>returnedClass()Deprecated, for removal: This API element is subject to removal in a future version.The class returned bynullSafeGet().voidsetParameterValues(Properties parameters)Deprecated, for removal: This API element is subject to removal in a future version.An instance of this class is "configured" by a call tosetParameterValues(java.util.Properties), where configuration parameters are given as entries in aPropertiesobject.voidsetTypeConfiguration(TypeConfiguration typeConfiguration)Deprecated, for removal: This API element is subject to removal in a future version.StringtoLoggableString(Object value, SessionFactoryImplementor factory)Deprecated, for removal: This API element is subject to removal in a future version.Generate a loggable string representation of the collection (value).StringtoSqlLiteral(T value)Deprecated, for removal: This API element is subject to removal in a future version.Return an SQL literal representation of the valueStringtoString(T value)Deprecated, for removal: This API element is subject to removal in a future version.Render the value to the string representation.-
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
-
-
-
-
Field Detail
-
ENUM
public static final String ENUM
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
NAMED
public static final String NAMED
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
TYPE
public static final String TYPE
Deprecated, for removal: This API element is subject to removal in a future version.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EnumType
public EnumType()
Deprecated, for removal: This API element is subject to removal in a future version.
-
EnumType
public EnumType(Class<T> enumClass, EnumValueConverter<T,?> enumValueConverter, TypeConfiguration typeConfiguration)
Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Detail
-
getEnumValueConverter
public EnumValueConverter<T,?> getEnumValueConverter()
Deprecated, for removal: This API element is subject to removal in a future version.
-
getJdbcType
public JdbcType getJdbcType(TypeConfiguration typeConfiguration)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserType- Specified by:
getJdbcTypein interfaceUserType<T extends Enum<T>>
-
getValueConverter
public BasicValueConverter<T,Object> getValueConverter()
Deprecated, for removal: This API element is subject to removal in a future version.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 extends Enum<T>>
-
setParameterValues
public void setParameterValues(Properties parameters)
Deprecated, for removal: This API element is subject to removal in a future version.An instance of this class is "configured" by a call to
setParameterValues(java.util.Properties), where configuration parameters are given as entries in aPropertiesobject. There are two distinct ways an instance may be configured:- one for
hbm.xml-based mapping, and - another for annotation-based or
orm.xml-based mapping.
In the case of annotations or
orm.xml, aDynamicParameterizedType.ParameterTypeis passed tosetParameterValues(java.util.Properties)under the key "org.hibernate.type.ParameterType".But in the case of
hbm.xml, there are multiple parameters:- "enumClass", the name of the Java enumeration class.
- "useNamed", specifies if the enum should be mapped by name. Default is to map as ordinal.
- "type", a JDBC type code (legacy alternative to "useNamed").
- Specified by:
setParameterValuesin interfaceParameterizedType
- one for
-
getSqlType
public int getSqlType()
Deprecated, for removal: This API element is subject to removal in a future version.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.
-
returnedClass
public Class<T> returnedClass()
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserTypeThe class returned bynullSafeGet().- Specified by:
returnedClassin interfaceUserType<T extends Enum<T>>- Returns:
- Class
-
equals
public boolean equals(T x, T y) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.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.
-
hashCode
public int hashCode(T x) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.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 of persistence "equality" for this custom type.
-
nullSafeGet
public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException
Deprecated, for removal: This API element is subject to removal in a future version.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 extends Enum<T>>- Throws:
SQLException
-
nullSafeSet
public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException
Deprecated, for removal: This API element is subject to removal in a future version.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 extends Enum<T>>- Throws:
HibernateExceptionSQLException
-
deepCopy
public T deepCopy(T value) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.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.
-
isMutable
public boolean isMutable()
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserTypeAre instances of the Java class mapped by this custom type mutable or immutable?
-
disassemble
public Serializable disassemble(T value) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserTypeTransform the given value into a destructured representation, suitable for storage in the second-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 extends Enum<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) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserTypeReconstruct a value from its destructured representation, during the process of reading the properties of an entity from 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.
-
replace
public T replace(T original, T target, Object owner) throws HibernateException
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:UserTypeDuring merge, replace the existing (target) value in the managed entity we are merging to with a new (original) value from the detached entity we are merging.- For immutable objects, or null values, it's safe to simply return the first argument.
- For mutable objects, it's enough to return a copy of the first argument.
- For objects with component values, it might make sense to recursively replace component values.
- Specified by:
replacein interfaceUserType<T extends Enum<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- See Also:
Session.merge(Object)
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
getTypeConfigurationin interfaceTypeConfigurationAware
-
setTypeConfiguration
public void setTypeConfiguration(TypeConfiguration typeConfiguration)
Deprecated, for removal: This API element is subject to removal in a future version.- Specified by:
setTypeConfigurationin interfaceTypeConfigurationAware
-
toSqlLiteral
public String toSqlLiteral(T value)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:EnhancedUserTypeReturn an SQL literal representation of the value- Specified by:
toSqlLiteralin interfaceEnhancedUserType<T extends Enum<T>>
-
toString
public String toString(T value)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:EnhancedUserTypeRender the value to the string representation.- Specified by:
toStringin interfaceEnhancedUserType<T extends Enum<T>>- Parameters:
value- The value to render to string.- Returns:
- The string representation
-
fromStringValue
public T fromStringValue(CharSequence sequence)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:EnhancedUserTypeConsume the given string representation back into this types java form.- Specified by:
fromStringValuein interfaceEnhancedUserType<T extends Enum<T>>- Parameters:
sequence- The string representation to be consumed.- Returns:
- The java type representation
-
toLoggableString
public String toLoggableString(Object value, SessionFactoryImplementor factory)
Deprecated, for removal: This API element is subject to removal in a future version.Description copied from interface:LoggableUserTypeGenerate a loggable string representation of the collection (value).- Specified by:
toLoggableStringin interfaceLoggableUserType- Parameters:
value- The collection to be logged; guaranteed to be non-null and initialized.factory- The factory.- Returns:
- The loggable string representation.
-
isOrdinal
public boolean isOrdinal()
Deprecated, for removal: This API element is subject to removal in a future version.
-
-