org.itracker.persistence.dao
Class AbstractEnumUserType

java.lang.Object
  extended by org.itracker.persistence.dao.AbstractEnumUserType
All Implemented Interfaces:
org.hibernate.usertype.EnhancedUserType, org.hibernate.usertype.ParameterizedType, org.hibernate.usertype.UserType
Direct Known Subclasses:
EnumCodeUserType, EnumNameUserType, EnumOrdinalUserType

public abstract class AbstractEnumUserType
extends Object
implements org.hibernate.usertype.EnhancedUserType, org.hibernate.usertype.ParameterizedType

Base class for custom Hibernate UserTypes to persist a Java 5 enum constant.

This is a parameterized type, which requires the following parameter : enumClassName = fully qualified name of the enum class to persist.

Example of inline mapping :

  
   
   
     com.company.project.Suit
   
  
 

Example of typedef :

  
    com.company.project.Suit
  

  
   
   
   
 

Author:
johnny

Field Summary
protected  Class<? extends Enum> enumClass
           
 
Constructor Summary
AbstractEnumUserType()
           
 
Method Summary
 Object assemble(Serializable cached, Object owner)
           
 Object deepCopy(Object value)
           
 Serializable disassemble(Object value)
           
 boolean equals(Object x, Object y)
           
 int hashCode(Object x)
           
 boolean isMutable()
           
 Object replace(Object original, Object target, Object owner)
           
 Class<?> returnedClass()
           
 void setParameterValues(Properties parameters)
           
 
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.EnhancedUserType
fromXMLString, objectToSQLString, toXMLString
 
Methods inherited from interface org.hibernate.usertype.UserType
nullSafeGet, nullSafeSet, sqlTypes
 

Field Detail

enumClass

protected Class<? extends Enum> enumClass
Constructor Detail

AbstractEnumUserType

public AbstractEnumUserType()
Method Detail

setParameterValues

public void setParameterValues(Properties parameters)
Specified by:
setParameterValues in interface org.hibernate.usertype.ParameterizedType

assemble

public Object assemble(Serializable cached,
                       Object owner)
                throws org.hibernate.HibernateException
Specified by:
assemble in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

deepCopy

public Object deepCopy(Object value)
                throws org.hibernate.HibernateException
Specified by:
deepCopy in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

disassemble

public Serializable disassemble(Object value)
                         throws org.hibernate.HibernateException
Specified by:
disassemble in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

equals

public boolean equals(Object x,
                      Object y)
               throws org.hibernate.HibernateException
Specified by:
equals in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

hashCode

public int hashCode(Object x)
             throws org.hibernate.HibernateException
Specified by:
hashCode in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

isMutable

public boolean isMutable()
Specified by:
isMutable in interface org.hibernate.usertype.UserType

replace

public Object replace(Object original,
                      Object target,
                      Object owner)
               throws org.hibernate.HibernateException
Specified by:
replace in interface org.hibernate.usertype.UserType
Throws:
org.hibernate.HibernateException

returnedClass

public Class<?> returnedClass()
Specified by:
returnedClass in interface org.hibernate.usertype.UserType


Copyright © 2002-2012 itracker. All Rights Reserved.