You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by David Graham <gr...@yahoo.com> on 2003/10/20 17:59:50 UTC

[dbutils] Enhanced* classes

The Enhanced* classes don't really seem to be enhanced versions of their
standard counterparts.  For example, EnhancedResultSet has this method:

public Long getLongObject(String column) throws SQLException {
    return new Long(getLong(column));
}

How is that enhanced over the standard rs.getObject(col) which performs
automatic type conversions or new Long(rs.getLong(col)) ?

To use these enhanced methods you must cast to the specific implementation
class you're using which is a poor practice.  It's been nearly a year
since they were first committed and haven't been updated since.

If no one is opposed, I'll remove these classes tommorrow.

David

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Re: [dbutils] Enhanced* classes

Posted by Juozas Baliuka <ba...@centras.lt>.
----- Original Message -----
From: "Henri Yandell" <ba...@generationjava.com>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Tuesday, October 21, 2003 7:18 AM
Subject: Re: [dbutils] Enhanced* classes


>
> I object to deleting them, but agree they don't offer much.
>
> They really exist as an example of the 'driver' package, and should move
> into some kind of example documentation. They would make a better example
> if the setLong/getLong methods do the null checking.
>
> Switching to using DynamicProxies for driver would make more sense as it
> would allow the JDBC 1/2/3 issue to become a non-issue. I plan to start
> looking into this so all of the driver package may become a pre-jdk-1.3
> thing and be ignored (?). Bit confused as to whether CGLib offers anything
> here.

It is possible to use CGLib for jdk1.2, but I do not think it is a good idea
to add dependancy
for this feature only, JDBC decorators need nothing more than jdk Proxy and
can run without security configuration.


>
> Hen
>
> On Mon, 20 Oct 2003, David Graham wrote:
>
> >
> > --- Tomasz Pik <pi...@ais.pl> wrote:
> > > David Graham wrote:
> > >
> > > > The Enhanced* classes don't really seem to be enhanced versions of
> > > their
> > > > standard counterparts.  For example, EnhancedResultSet has this
> > > method:
> > > >
> > > > public Long getLongObject(String column) throws SQLException {
> > > >     return new Long(getLong(column));
> > > > }
> > >
> > > What about:
> > >
> > > public Long getLongObject(String column) throws SQLException {
> > >      long result = getLong(column);
> > >      if (wasNull()) {
> > >          return null;
> > >      } else {
> > >          return new Long(result);
> > >      }
> > > }
> > >
> > > > How is that enhanced over the standard rs.getObject(col) which
> > > performs
> > > > automatic type conversions or new Long(rs.getLong(col)) ?
> > >
> > > Maybe this method check agains null too?
> >
> > There is a SqlNullCheckedResultSet wrapper class that assigns a default
> > value for null fields.  This conforms to the ResultSet interface so it
> > doesn't require casting to use it.
> >
> > David
> >
> > >
> > > Regards,
> > > Tomek
> > >
> > > > David
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > The New Yahoo! Shopping - with improved product search
> > http://shopping.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [dbutils] Enhanced* classes

Posted by Henri Yandell <ba...@generationjava.com>.
Go ahead and remove them. I'll remember they're in there and resurrect to
example/ as and when I get off my lazy arse :)

Hen

On Tue, 21 Oct 2003, David Graham wrote:

>
> --- Henri Yandell <ba...@generationjava.com> wrote:
> >
> > I object to deleting them, but agree they don't offer much.
> >
> > They really exist as an example of the 'driver' package, and should move
> > into some kind of example documentation. They would make a better
> > example
> > if the setLong/getLong methods do the null checking.
>
> Validator has a /src/example directory with classes under
> org.apache.commons.validator.example.  If you really want to keep them, we
> could move them to a similar structure.
>
> David
>
> >
> > Switching to using DynamicProxies for driver would make more sense as it
> > would allow the JDBC 1/2/3 issue to become a non-issue. I plan to start
> > looking into this so all of the driver package may become a pre-jdk-1.3
> > thing and be ignored (?). Bit confused as to whether CGLib offers
> > anything
> > here.
> >
> > Hen
> >
> > On Mon, 20 Oct 2003, David Graham wrote:
> >
> > >
> > > --- Tomasz Pik <pi...@ais.pl> wrote:
> > > > David Graham wrote:
> > > >
> > > > > The Enhanced* classes don't really seem to be enhanced versions of
> > > > their
> > > > > standard counterparts.  For example, EnhancedResultSet has this
> > > > method:
> > > > >
> > > > > public Long getLongObject(String column) throws SQLException {
> > > > >     return new Long(getLong(column));
> > > > > }
> > > >
> > > > What about:
> > > >
> > > > public Long getLongObject(String column) throws SQLException {
> > > >      long result = getLong(column);
> > > >      if (wasNull()) {
> > > >          return null;
> > > >      } else {
> > > >          return new Long(result);
> > > >      }
> > > > }
> > > >
> > > > > How is that enhanced over the standard rs.getObject(col) which
> > > > performs
> > > > > automatic type conversions or new Long(rs.getLong(col)) ?
> > > >
> > > > Maybe this method check agains null too?
> > >
> > > There is a SqlNullCheckedResultSet wrapper class that assigns a
> > default
> > > value for null fields.  This conforms to the ResultSet interface so it
> > > doesn't require casting to use it.
> > >
> > > David
> > >
> > > >
> > > > Regards,
> > > > Tomek
> > > >
> > > > > David
> > > >
> > > >
> > > >
> > > >
> > > >
> > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > The New Yahoo! Shopping - with improved product search
> > > http://shopping.yahoo.com
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [dbutils] Enhanced* classes

Posted by David Graham <gr...@yahoo.com>.
--- Henri Yandell <ba...@generationjava.com> wrote:
> 
> I object to deleting them, but agree they don't offer much.
> 
> They really exist as an example of the 'driver' package, and should move
> into some kind of example documentation. They would make a better
> example
> if the setLong/getLong methods do the null checking.

Validator has a /src/example directory with classes under
org.apache.commons.validator.example.  If you really want to keep them, we
could move them to a similar structure.

David

> 
> Switching to using DynamicProxies for driver would make more sense as it
> would allow the JDBC 1/2/3 issue to become a non-issue. I plan to start
> looking into this so all of the driver package may become a pre-jdk-1.3
> thing and be ignored (?). Bit confused as to whether CGLib offers
> anything
> here.
> 
> Hen
> 
> On Mon, 20 Oct 2003, David Graham wrote:
> 
> >
> > --- Tomasz Pik <pi...@ais.pl> wrote:
> > > David Graham wrote:
> > >
> > > > The Enhanced* classes don't really seem to be enhanced versions of
> > > their
> > > > standard counterparts.  For example, EnhancedResultSet has this
> > > method:
> > > >
> > > > public Long getLongObject(String column) throws SQLException {
> > > >     return new Long(getLong(column));
> > > > }
> > >
> > > What about:
> > >
> > > public Long getLongObject(String column) throws SQLException {
> > >      long result = getLong(column);
> > >      if (wasNull()) {
> > >          return null;
> > >      } else {
> > >          return new Long(result);
> > >      }
> > > }
> > >
> > > > How is that enhanced over the standard rs.getObject(col) which
> > > performs
> > > > automatic type conversions or new Long(rs.getLong(col)) ?
> > >
> > > Maybe this method check agains null too?
> >
> > There is a SqlNullCheckedResultSet wrapper class that assigns a
> default
> > value for null fields.  This conforms to the ResultSet interface so it
> > doesn't require casting to use it.
> >
> > David
> >
> > >
> > > Regards,
> > > Tomek
> > >
> > > > David
> > >
> > >
> > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > The New Yahoo! Shopping - with improved product search
> > http://shopping.yahoo.com
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Re: [dbutils] Enhanced* classes

Posted by Henri Yandell <ba...@generationjava.com>.
I object to deleting them, but agree they don't offer much.

They really exist as an example of the 'driver' package, and should move
into some kind of example documentation. They would make a better example
if the setLong/getLong methods do the null checking.

Switching to using DynamicProxies for driver would make more sense as it
would allow the JDBC 1/2/3 issue to become a non-issue. I plan to start
looking into this so all of the driver package may become a pre-jdk-1.3
thing and be ignored (?). Bit confused as to whether CGLib offers anything
here.

Hen

On Mon, 20 Oct 2003, David Graham wrote:

>
> --- Tomasz Pik <pi...@ais.pl> wrote:
> > David Graham wrote:
> >
> > > The Enhanced* classes don't really seem to be enhanced versions of
> > their
> > > standard counterparts.  For example, EnhancedResultSet has this
> > method:
> > >
> > > public Long getLongObject(String column) throws SQLException {
> > >     return new Long(getLong(column));
> > > }
> >
> > What about:
> >
> > public Long getLongObject(String column) throws SQLException {
> >      long result = getLong(column);
> >      if (wasNull()) {
> >          return null;
> >      } else {
> >          return new Long(result);
> >      }
> > }
> >
> > > How is that enhanced over the standard rs.getObject(col) which
> > performs
> > > automatic type conversions or new Long(rs.getLong(col)) ?
> >
> > Maybe this method check agains null too?
>
> There is a SqlNullCheckedResultSet wrapper class that assigns a default
> value for null fields.  This conforms to the ResultSet interface so it
> doesn't require casting to use it.
>
> David
>
> >
> > Regards,
> > Tomek
> >
> > > David
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search
> http://shopping.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


Re: [dbutils] Enhanced* classes

Posted by David Graham <gr...@yahoo.com>.
--- Tomasz Pik <pi...@ais.pl> wrote:
> David Graham wrote:
> 
> > The Enhanced* classes don't really seem to be enhanced versions of
> their
> > standard counterparts.  For example, EnhancedResultSet has this
> method:
> > 
> > public Long getLongObject(String column) throws SQLException {
> >     return new Long(getLong(column));
> > }
> 
> What about:
> 
> public Long getLongObject(String column) throws SQLException {
>      long result = getLong(column);
>      if (wasNull()) {
>          return null;
>      } else {
>          return new Long(result);
>      }
> }
> 
> > How is that enhanced over the standard rs.getObject(col) which
> performs
> > automatic type conversions or new Long(rs.getLong(col)) ?
> 
> Maybe this method check agains null too?

There is a SqlNullCheckedResultSet wrapper class that assigns a default
value for null fields.  This conforms to the ResultSet interface so it
doesn't require casting to use it.

David

> 
> Regards,
> Tomek
> 
> > David
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

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


Re: [dbutils] Enhanced* classes

Posted by Tomasz Pik <pi...@ais.pl>.
David Graham wrote:

> The Enhanced* classes don't really seem to be enhanced versions of their
> standard counterparts.  For example, EnhancedResultSet has this method:
> 
> public Long getLongObject(String column) throws SQLException {
>     return new Long(getLong(column));
> }

What about:

public Long getLongObject(String column) throws SQLException {
     long result = getLong(column);
     if (wasNull()) {
         return null;
     } else {
         return new Long(result);
     }
}

> How is that enhanced over the standard rs.getObject(col) which performs
> automatic type conversions or new Long(rs.getLong(col)) ?

Maybe this method check agains null too?

Regards,
Tomek

> David




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