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 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>
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassemble(Serializable cached, Object owner) disassemble(Object value) booleanintbooleannullSafeGet(ResultSet rs, String[] names, Object owner) voidnullSafeSet(PreparedStatement st, Object value, int index) voidsetParameterValues(Properties parameters) int[]sqlTypes()
-
Constructor Details
-
GenericEnumUserType
public GenericEnumUserType()
-
-
Method Details
-
setParameterValues
- Specified by:
setParameterValuesin interfaceorg.hibernate.usertype.ParameterizedType
-
returnedClass
- Specified by:
returnedClassin interfaceorg.hibernate.usertype.UserType
-
nullSafeGet
public Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws org.hibernate.HibernateException, SQLException - Specified by:
nullSafeGetin interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateExceptionSQLException
-
nullSafeSet
public void nullSafeSet(PreparedStatement st, Object value, int index) throws org.hibernate.HibernateException, SQLException - Specified by:
nullSafeSetin interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateExceptionSQLException
-
sqlTypes
public int[] sqlTypes()- Specified by:
sqlTypesin interfaceorg.hibernate.usertype.UserType
-
assemble
- Specified by:
assemblein interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-
deepCopy
- Specified by:
deepCopyin interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-
disassemble
- Specified by:
disassemblein interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-
equals
- Specified by:
equalsin interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-
hashCode
- Specified by:
hashCodein interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-
isMutable
public boolean isMutable()- Specified by:
isMutablein interfaceorg.hibernate.usertype.UserType
-
replace
public Object replace(Object original, Object target, Object owner) throws org.hibernate.HibernateException - Specified by:
replacein interfaceorg.hibernate.usertype.UserType- Throws:
org.hibernate.HibernateException
-