POST QUESTIONS ON THE FORUM! COMMENTS HERE SHOULD ADD VALUE TO THE
PAGE!On 17 Jul 2005 21:08, KnisterPeter wrote:
>For sake of performace this method should be slightly modified:
>[code]
> 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;
> }
>[/code]
>to
>[code]
> public Object nullSafeGet(ResultSet resultSet, String[] names,
>Object owner) throws HibernateException, SQLException {
> E result = null;
> if (!resultSet.wasNull()) {
> String name = resultSet.getString(names[0]);
> result = Enum.valueOf(clazz, name);
> }
> return result;
> }
>[/code]
Actually, that won't work. According to the API doc for
ResultSet.wasNull: "Note that you must first call one of the getter
methods on a column to try to read its value and then call the method
wasNull to see if the value read was SQL NULL."
Cheers,
Søren |