Code example for ResultSet

Methods: getString, wasNull

0
   public Class returnedClass() {
       return clazz;
   } 
 
   public Object nullSafeGet(ResultSet resultSet, String[] names, Object owner) throws HibernateException, SQLException {
       String name = resultSet.getString(names[0]);
       E result = null;
       if (!resultSet.wasNull()) {
  	   result = Enum.valueOf(clazz, name);
       } 
       return result;
   } 
 
   public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException {
       if (null == value) {
  	   preparedStatement.setNull(index, Types.VARCHAR);
       } else { 
  	   preparedStatement.setString(index, ((Enum)value).name());
       } 
   }