Thread:
 Another way, using Field Reflection 
 ZellmoTheMagnificent   18 Aug 2005, 18:50 
 Re: Another way, using Field Reflection 
 phersh   27 Sep 2005, 19:21 
 Re: Another way, using Field Reflection 
 lkline   06 Oct 2005, 18:16 

Comment
Prev. thread 
 Next thread
 
Prev. posting 
 Next posting
From: phersh (27 Sep 2005, 19:21) Replies: 1, Views: 32036
Subject: Re: Another way, using Field Reflection
Hi,

The nullSafeGet doesn't protect from nulls because 

String value = resultSet.getString(names[0]); can return null.

I've changed nullSafeGet to:
    public Object nullSafeGet(ResultSet resultSet, String[] names,
Object owner)
            throws HibernateException, SQLException {
        if (resultSet.wasNull()) return null;
        String value = resultSet.getString(names[0]);
        if (value == null) return null;
        return getObject(value);
    }
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]