Jeff Blattman wrote:
one reason to use Boolean vs. boolean is if you want to know if
something has been set. there are actually three states: true, false,
and unset.
for example, in the admin API, an update request can be sparse. a
request to update a weblog might only contain the email address. when
the bean that represents the weblog is processed, i need to know if the
user passed in the enabled flag to know if i need to set it in the
WebsiteData object.
yeah, that makes sense, but in a pojo which is storing its info into a
database column which is set to 'boolean' that doesn't make sense.
I am starting to get the suspicion that we have been using Boolean in
the pojos because that way the auto-generated struts formbeans use
Boolean which is useful for the scenario you just described. However,
that's a pretty bastardized reason for making that decision in my mind.
This may serve as another example of why auto-generated formbeans may
not be the best solution.
-- Allen
Allen Gilliland wrote:
I'm not sure about this exact problem, but this does bring to mind one
issue that I had noticed a number of times around the use of Boolean
vs. boolean in Roller.
I noticed that in a number of places, including pojo methods, that we
use the java.lang.Boolean class instead of the boolean primitive type,
and I don't understand why. My problem with using the Boolean object
is that it kind of breaks the binary nature of a boolean. In my mind
a boolean should only have 2 states, true or false. But with a
Boolean you can have true, false, or null, which seems wrong to me.
This may or may not be related to Jeff's problem, but in any case I
think it would be a good idea to settle on a standard for which type
to use. I tend to prefer the primitive boolean type unless there is a
distinct reason we can't use it.
-- Allen
Jeff Blattman wrote:
from server admin -> user admin, if i uncheck enabled and click save,
then return to edit the same user again, enabled is still checked.
there is an error in the logs ...
/WARN 2006-10-06 09:33:27,652 JDBCExceptionReporter:logExceptions -
SQL Error: 0, SQLState: 01004
ERROR 2006-10-06 09:33:27,656 JDBCExceptionReporter:logExceptions -
Data truncation: Column set to default value; NULL supplied to NOT
NULL column 'isenabled' at row 1/
i think this is because if the checkbox is not set, the form comes
back with a value of null. this results in a
UserData.setEnabled(null), which causes the above exception.
i wasn't quite sure where to add the fix. set if null set to false in
UserData.setEnabled()?