Package com.jalios.jcms.db
Class GenericEnumUserType
- java.lang.Object
-
- com.jalios.jcms.db.GenericEnumUserType
-
- All Implemented Interfaces:
org.hibernate.usertype.ParameterizedType
,org.hibernate.usertype.UserType
public class GenericEnumUserType extends java.lang.Object implements org.hibernate.usertype.UserType, org.hibernate.usertype.ParameterizedType
If you need to map Java 5 Enums to Hibernate using JPA annotations this is what you are looking for.Example:
<hibernate-mapping> <typedef name="documentTypeEnum" class="com.jalios.jcms.db.GenericEnumUserType"> <param name="enumClass">com.jalios.jcmsplugin.myplugin.DocumentType</param> <!--<param name="identifierMethod">toInt</param>--> <!--default: name--> <!--<param name="valueOfMethod">fromInt</param>--> <!--default: valueOf--> </typedef> ... <property name="documentType" type="documentTypeEnum" /> <hibernate-mapping>
-
-
Constructor Summary
Constructors Constructor Description GenericEnumUserType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
assemble(java.io.Serializable cached, java.lang.Object owner)
java.lang.Object
deepCopy(java.lang.Object value)
java.io.Serializable
disassemble(java.lang.Object value)
boolean
equals(java.lang.Object x, java.lang.Object y)
int
hashCode(java.lang.Object x)
boolean
isMutable()
java.lang.Object
nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, java.lang.Object owner)
void
nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index)
java.lang.Object
replace(java.lang.Object original, java.lang.Object target, java.lang.Object owner)
java.lang.Class
returnedClass()
void
setParameterValues(java.util.Properties parameters)
int[]
sqlTypes()
-
-
-
Method Detail
-
setParameterValues
public void setParameterValues(java.util.Properties parameters)
- Specified by:
setParameterValues
in interfaceorg.hibernate.usertype.ParameterizedType
-
returnedClass
public java.lang.Class returnedClass()
- Specified by:
returnedClass
in interfaceorg.hibernate.usertype.UserType
-
nullSafeGet
public java.lang.Object nullSafeGet(java.sql.ResultSet rs, java.lang.String[] names, java.lang.Object owner) throws org.hibernate.HibernateException, java.sql.SQLException
- Specified by:
nullSafeGet
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
java.sql.SQLException
-
nullSafeSet
public void nullSafeSet(java.sql.PreparedStatement st, java.lang.Object value, int index) throws org.hibernate.HibernateException, java.sql.SQLException
- Specified by:
nullSafeSet
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
java.sql.SQLException
-
sqlTypes
public int[] sqlTypes()
- Specified by:
sqlTypes
in interfaceorg.hibernate.usertype.UserType
-
assemble
public java.lang.Object assemble(java.io.Serializable cached, java.lang.Object owner) throws org.hibernate.HibernateException
- Specified by:
assemble
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
deepCopy
public java.lang.Object deepCopy(java.lang.Object value) throws org.hibernate.HibernateException
- Specified by:
deepCopy
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
disassemble
public java.io.Serializable disassemble(java.lang.Object value) throws org.hibernate.HibernateException
- Specified by:
disassemble
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
equals
public boolean equals(java.lang.Object x, java.lang.Object y) throws org.hibernate.HibernateException
- Specified by:
equals
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
hashCode
public int hashCode(java.lang.Object x) throws org.hibernate.HibernateException
- Specified by:
hashCode
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
isMutable
public boolean isMutable()
- Specified by:
isMutable
in interfaceorg.hibernate.usertype.UserType
-
replace
public java.lang.Object replace(java.lang.Object original, java.lang.Object target, java.lang.Object owner) throws org.hibernate.HibernateException
- Specified by:
replace
in interfaceorg.hibernate.usertype.UserType
- Throws:
org.hibernate.HibernateException
-
-