Is there a way to tell Cayenne to return some other value than null
when the database contains null?
E.g. for String I want an empty string instead of null, for Integer I
want 0 instead of null, etc.
Also, I want Cayenne not to modify the database unecessarily, e.g. if
Cayenne returns "" when the database contains NULL and I write back
"" to the database, I don't want Cayenne to write an empty string to
the database, but leave the database unchanged, yet there needs to be
a way to set such database null strings to "".
My personal favourite solution to null pointer problem is
polymorphism. Create a subclass which handles the "null", "empty",
case, etc. One annoying thing about null pointers is that they are
typeless. I would have created a NullString subclass to String in some
cases, except String is final. BigDecimal is not final, so the trick
could work there. Since I'm already on my hobbyhorse: null pointers
are a plague. Much too easy to misuse. Look at the number of bug
reports in e.g. Eclipse that are NPE's(ca. 15000 out of 150000) and
the number of != null or == null checks in Eclipse is just staggering.
It vastly complicates the code. Oh well. :-)
-- Øyvind Harboe http://www.zylin.com
This archive was generated by hypermail 2.0.0 : Thu Aug 03 2006 - 16:03:03 EDT