commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Shea <s...@gtsdesign.com>
Subject Re: [BeanUtils] ResultSetDynaClass lowerCase option
Date Mon, 06 Oct 2003 20:16:54 GMT
"Goes boom" _is_ rather inexact...

I acquire a ResultSet.  I have verified that the ResultSet contains
three rows, each containing one column: "SOMEDATA".  The underlying db
is hsqldb.  The code is pretty much drawn from the doc pages:

    ResultSetDynaClass rsdc = new ResultSetDynaClass(resultSet, true);
    DynaProperty properties[] = rsdc.getDynaProperties();
    Iterator rows = rsdc.iterator();
    int rowCount = 0;
    while (rows.hasNext()) {
        if (_logger.isDebugEnabled()) {
            _logger.debug("rowCount: " + rowCount++);
        }
        DynaBean openRow = (DynaBean) rows.next();
        if (_logger.isDebugEnabled()) {
            for (int i = 0; i < properties.length; ++i) {
                if (_logger.isDebugEnabled()) {
                    _logger.debug("column " + i);
                }
                DynaProperty prop = properties[i];
                String name = prop.getName();
                _logger.debug(name + ": <" + openRow.get(name) + ">");
            } 
        }
    }

The following exception is thrown in the first call to openRow.get(name):

    [junit] java.lang.RuntimeException: get(somedata): SQLException:
java.sql.SQLException: Column not found: somedata
    [junit]     at
org.apache.commons.beanutils.ResultSetIterator.get(ResultSetIterator.java:163)

which indicates to me that the name used was indeed "somedata" not
"SOMEDATA", so I'm not sure if this is a bug or not.  But, it appears to
me that setting lowerCase to true will always result in an exception
unless the name returned by the db is already lower-case, so I don't see
the utility of it.  Again, my apologies if I'm being dense.

Regards,

        Gary






[2003-10-06 10:05 -0700] Craig R. McClanahan (craigmcc@apache.org) wrote:

> Gary Shea wrote:
> 
> >I've run into a situation where the ResultSet DynaClass support is
> >broken by setting the lowerCase field true.  Hsqldb sets column names to
> >upper case by default.  If lowerCase is true, the first access to the
> >row goes boom.  I'm wondering if this is because lowerCase is a work in
> >progress, or because this is expected behavior?  The javadoc suggests
> >that lowerCase is intended to ease dealing with varying JDBC
> >implementations, but my impression of the current lowerCase code is that
> >it's very fragile and will only work if the JDBC implementation returns
> >the column names in lower case already!  My apologies if I'm missing
> >something...
> >  
> >
> Without a specific example of what "goes boom" means, it is not possible 
> to tell whether this is a bug in BeanUtils or a user error.  However, 
> the design intent of the "lowerCase" flag is that, no matter what the 
> database returns for column names, the *entire* property name (as seen 
> in the DynaBeans) is in lower case.  For example, if your database 
> returned "ACCOUNT_ID" as a column name, the property in DynaBeans would 
> be treated as "account_id" instead.
> 
> If you are seeing something different, please post a bug report with a 
> detailed example:
> 
>   http://nagoya.apache.org/bugzilla
> 
> 
> >I'm happy to contribute a fix, if something needs fixing, but thought
> >I'd better check first...
> >
> >Regards,
> >
> >        Gary
> >  
> >
> Craig
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message