Issue Details (XML | Word | Printable)

Key: DBUTILS-3
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Unassigned
Reporter: Tim Bailen
Votes: 1
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Commons DbUtils

[dbutils] Setting bean properties fails silently

Created: 30/Dec/05 07:47 AM   Updated: 02/Jan/08 07:29 AM
Return to search
Component/s: None
Affects Version/s: None
Fix Version/s: 1.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works patch-DBUTILS-3.txt 2006-11-01 03:28 PM Alan B. Canon 0.7 kB
Environment:
Operating System: other
Platform: Other

Bugzilla Id: 38076
Resolution Date: 02/Nov/06 06:08 AM


 Description  « Hide
I had a property in my bean that wasn't being set by BeanHandler. No matter
the value of the matching field name in the database, the value in the bean
would always come back as 0.

I traced the culprit to BasicRowProcessor.callSetter(), which calls the
setter method on the bean corresponding to the same field name in the
database. Before it attempts to call the setter, it checks to make sure that
the type of the value retrieved from the database is compatible with the type
of the bean. This behavior is fair enough, but if the types are determined to
be incompatible, DBUtils essentially fails silently. That is, it does not call
the setter and it does nothing to inform the developer that this is what
happened.

This was frustrating for me because I had a field that was type int in my bean
and type long in the database, but I didn't realize why it wasn't being set
until I stepped through the code.

POSSIBLE RESOLUTIONS
--------------------
1. Start a FAQ for DBUtils and mention that a bean's property will not be
initialized if its type is incompatible with the corresponding field in the
database

2. Log some message to this effect when it occurs (I don't believe DBUtils has
any logging, so this probably isn't viable)

3. Throw an exception when this case occurs. Better that the program fail
obviously and with some information about what happened rather than return a
bean in an invalid state.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Henri Yandell made changes - 16/May/06 10:04 AM
Field Original Value New Value
issue.field.bugzillaimportkey 38076 12342825
Henri Yandell made changes - 16/May/06 11:29 AM
Component/s DbUtils [ 12311110 ]
Assignee Jakarta Commons Developers Mailing List [ commons-dev@jakarta.apache.org ]
Key COM-2673 DBUTILS-3
Affects Version/s unspecified [ 12311647 ]
Project Commons [ 12310458 ] Commons DbUtils [ 12310470 ]
Henri Yandell made changes - 19/Jul/06 06:24 AM
Bugzilla Id 38076
Fix Version/s 1.1 [ 12311973 ]
Alan B. Canon made changes - 01/Nov/06 03:28 PM
Attachment patch-DBUTILS-3.txt [ 12344107 ]
Henri Yandell made changes - 02/Nov/06 06:08 AM
Status Open [ 1 ] Resolved [ 5 ]
Resolution Fixed [ 1 ]
Henri Yandell made changes - 02/Jan/08 07:29 AM
Status Resolved [ 5 ] Closed [ 6 ]