public class EnumToStringType extends EnumType
{
@Override
public int[] sqlTypes()
{ return new int[] { Types.VARCHAR }; }
@Override
public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session)
throws HibernateException, SQLException
{
if ( value == null )
{ super.nullSafeSet(st, value, index, session); }
else
{
String enumString = ( (Enum<?>) value ).name();
st.setObject( index, enumString, sqlTypes()[0] );
}
}
}