commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 38076] New: - setting bean properties fails silently
Date Thu, 29 Dec 2005 22:47:20 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38076>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38076

           Summary: setting bean properties fails silently
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DbUtils
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: bailen@cs.wisc.edu


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.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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


Mime
View raw message