public class

EnumType

extends Object
implements Serializable EnhancedUserType ParameterizedType
java.lang.Object
   ↳ org.hibernate.type.EnumType

Class Overview

Enum type mapper Try and find the appropriate SQL type depending on column metadata

TODO implements readobject/writeobject to recalculate the enumclasses

Summary

Constants
String CATALOG
String COLUMN
String ENUM
String SCHEMA
String TABLE
String TYPE
Public Constructors
EnumType()
Public Methods
Object assemble(Serializable cached, Object owner)
Reconstruct an object from the cacheable representation.
Object deepCopy(Object value)
Return a deep copy of the persistent state, stopping at entities and at collections.
Serializable disassemble(Object value)
Transform the object into its cacheable representation.
boolean equals(Object x, Object y)
Compare two instances of the class mapped by this type for persistence "equality".
Object fromXMLString(String xmlValue)
Parse a string representation of this value, as it appears in an XML document
int hashCode(Object x)
Get a hashcode for the instance, consistent with persistence "equality"
boolean isMutable()
Are objects of this type mutable?
Object nullSafeGet(ResultSet rs, String[] names, Object owner)
Retrieve an instance of the mapped class from a JDBC resultset.
void nullSafeSet(PreparedStatement st, Object value, int index)
Write an instance of the mapped class to a prepared statement.
String objectToSQLString(Object value)
Return an SQL literal representation of the value
Object replace(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().
void setParameterValues(Properties parameters)
Gets called by Hibernate to pass the configured type parameters to the implementation.
int[] sqlTypes()
Return the SQL type codes for the columns mapped by this type.
String toXMLString(Object value)
Return a string representation of this value, as it should appear in an XML document
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.hibernate.usertype.EnhancedUserType
From interface org.hibernate.usertype.ParameterizedType
From interface org.hibernate.usertype.UserType

Constants

public static final String CATALOG

Constant Value: "catalog"

public static final String COLUMN

Constant Value: "column"

public static final String ENUM

Constant Value: "enumClass"

public static final String SCHEMA

Constant Value: "schema"

public static final String TABLE

Constant Value: "table"

public static final String TYPE

Constant Value: "type"

Public Constructors

public EnumType ()

Public Methods

public Object assemble (Serializable cached, Object owner)

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)

Parameters
cached the object to be cached
owner the owner of the cached object
Returns
  • a reconstructed object from the cachable representation

public Object deepCopy (Object value)

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.

Parameters
value the object to be cloned, which may be null
Returns
  • Object a copy

public Serializable disassemble (Object value)

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)

Parameters
value the object to be cached
Returns
  • a cachable representation of the object

public boolean equals (Object x, Object y)

Compare two instances of the class mapped by this type for persistence "equality". Equality of the persistent state.

Returns
  • boolean

public Object fromXMLString (String xmlValue)

Parse a string representation of this value, as it appears in an XML document

public int hashCode (Object x)

Get a hashcode for the instance, consistent with persistence "equality"

public boolean isMutable ()

Are objects of this type mutable?

Returns
  • boolean

public Object nullSafeGet (ResultSet rs, String[] names, Object owner)

Retrieve an instance of the mapped class from a JDBC resultset. Implementors should handle possibility of null values.

Parameters
rs a JDBC result set
names the column names
owner the containing entity
Returns
  • Object

public void nullSafeSet (PreparedStatement st, Object value, int index)

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.

Parameters
st a JDBC prepared statement
value the object to write
index statement parameter index

public String objectToSQLString (Object value)

Return an SQL literal representation of the value

public Object replace (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. 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.

Parameters
original the value from the detached entity being merged
target the value in the managed entity
Returns
  • the value to be merged

public Class<? extends Enum> returnedClass ()

The class returned by nullSafeGet().

Returns
  • Class

public void setParameterValues (Properties parameters)

Gets called by Hibernate to pass the configured type parameters to the implementation.

public int[] sqlTypes ()

Return the SQL type codes for the columns mapped by this type. The codes are defined on java.sql.Types.

Returns
  • int[] the typecodes

public String toXMLString (Object value)

Return a string representation of this value, as it should appear in an XML document