org.itracker.persistence.dao
Class EnumOrdinalUserType
java.lang.Object
org.itracker.persistence.dao.AbstractEnumUserType
org.itracker.persistence.dao.EnumOrdinalUserType
- All Implemented Interfaces:
- org.hibernate.usertype.EnhancedUserType, org.hibernate.usertype.ParameterizedType, org.hibernate.usertype.UserType
public final class EnumOrdinalUserType
- extends AbstractEnumUserType
Custom Hibernate UserType to persist a Java 5 enum constant as an INTEGER
using its ordinal position.
Beware that the enum.ordinal() returns a is zero based that changes
if the position of the enum members change!
- Author:
- johnny
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
EnumOrdinalUserType
public EnumOrdinalUserType()
- Default constructor, required by Hibernate.
setParameterValues
public void setParameterValues(Properties parameters)
- Specified by:
setParameterValues in interface org.hibernate.usertype.ParameterizedType- Overrides:
setParameterValues in class AbstractEnumUserType
nullSafeGet
public Object nullSafeGet(ResultSet rs,
String[] names,
Object owner)
throws org.hibernate.HibernateException,
SQLException
- Throws:
org.hibernate.HibernateException
SQLException
nullSafeSet
public void nullSafeSet(PreparedStatement stmt,
Object value,
int index)
throws org.hibernate.HibernateException,
SQLException
- Throws:
org.hibernate.HibernateException
SQLException
sqlTypes
public int[] sqlTypes()
objectToSQLString
public String objectToSQLString(Object value)
toXMLString
public String toXMLString(Object value)
fromXMLString
public Object fromXMLString(String xmlValue)
Copyright © 2002-2012 itracker. All Rights Reserved.