Uploaded image for project: 'Commons DbUtils'
  1. Commons DbUtils
  2. DBUTILS-113

Add support for conversion of ResultSet strings to enums in the BeanProcessor

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.6

    Description

      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.

      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)

      It seems to me that commons-dbutils should be able to handle this conversion.

      Attachments

        1. bean_enums.diff
          4 kB
          Graylin Kim
        2. bean_enums2.diff
          4 kB
          Graylin Kim
        3. bean_enums3.diff
          4 kB
          Graylin Kim
        4. bean_enums4.patch
          12 kB
          Graylin Kim
        5. DBUTILS-113.patch
          13 kB
          Michael Osipov
        6. DBUTILS-113.patch
          3 kB
          Michael Osipov

        Activity

          People

            britter Benedikt Ritter
            graylinkim Graylin Kim
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: