Thread:
 Performance and memfootprint optimisation 
 KnisterPeter   17 Jul 2005, 21:08 
 Re: Performance and memfootprint optimisation 
 sorenlarsen   28 Jul 2005, 05:46 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: sorenlarsen (28 Jul 2005, 05:46) Replies: 0, Views: 37013
Subject: Re: Performance and memfootprint optimisation
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
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
© Copyright 2006, Red Hat Middleware, LLC. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc. [Privacy Policy]