commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Graylin Kim (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (DBUTILS-113) Add support for conversion of ResultSet strings to enums in the BeanProcessor
Date Wed, 13 Nov 2013 21:15:21 GMT

     [ https://issues.apache.org/jira/browse/DBUTILS-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Graylin Kim updated DBUTILS-113:
--------------------------------

    Attachment: bean_enums4.patch

Ah, cast asSubclass. Neat, I didn't realize Java had this capability.

Why couldn't we catch the ClassCastException and rethrow as a SQLException like we do the
other runtime errors? Or is that not what you mean by "Unchecked cast which might be ignored"?

Sorry about the other test failures, I should have been running all of them. Attached is your
patch modified to pass all tests.

> Add support for conversion of ResultSet strings to enums in the BeanProcessor
> -----------------------------------------------------------------------------
>
>                 Key: DBUTILS-113
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-113
>             Project: Commons DbUtils
>          Issue Type: Improvement
>            Reporter: Graylin Kim
>            Priority: Minor
>              Labels: patch
>         Attachments: DBUTILS-113.patch, bean_enums.diff, bean_enums2.diff, bean_enums3.diff,
bean_enums4.patch
>
>
> When using commons-dbutils I frequently use enum values with corresponding enum in the
database. In this situation, using the BeanListHandler produces the following exception causing
me to write a custom bean handler for enum conversion.
> {quote}
> Cannot set status: incompatible types, cannot convert java.lang.String to gov.nysenate.openleg.util.Storage$Status
Query: SELECT * FROM changelog WHERE 1=1 AND time >= ? AND time <= ? Parameters: [2013-07-24
00:00:00, 2013-07-26 23:59:59]
> java.sql.SQLException: Cannot set status: incompatible types, cannot convert java.lang.String
to gov.nysenate.openleg.util.Storage$Status Query: SELECT * FROM changelog WHERE 1=1 AND time
>= ? AND time <= ? Parameters: [2013-07-24 00:00:00, 2013-07-26 23:59:59]
> 	at org.apache.commons.dbutils.AbstractQueryRunner.rethrow(AbstractQueryRunner.java:363)
> 	at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:350)
> 	at org.apache.commons.dbutils.QueryRunner.query(QueryRunner.java:288)
> {quote}
> It seems to me that commons-dbutils should be able to handle this conversion.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message