So this is not about syncing with DB defaults?
Then I think that's over-engineered. Would it be easier to simply
override needed getters per entity class and do "return super is
null ? defaultVal : super", without changing Cayenne core?
Andrus
On Aug 20, 2008, at 12:46 PM, Øyvind Harboe wrote:
One way to handle database NULL (replace with default value)
is to override the CayenneDataObject get/set methods.
However, I was wondering if it would make sense to add a column
to DbEntity in the modeler for this case.
The idea is that this "documents" the behaviour in the modeler for
what happens in this case for a column. It also saves a tad of
Java boilerplate code.
I would expect the default value to behave as follows:
default value = null. Same as today.
default value != null:
- return default value upon getXxx() methods (readProperty()) when
database column contains NULL
- setProperty() w/default value upon column w/database NULL. Probably
update the database upon commit. This would cause database NULL
to be updated to default value when rewinding/submitting a form
without
actually making any changes to a form(using tapestry rewinding
wording above...)
- I'm not quite sure if I have decided what to expect from
Expression's.
If I search for a value in the database that is equal to the default
value,
would I then expect rows w/NULL to match? Probably not.
--
Øyvind Harboe
http://www.zylin.com/zy1000.html
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer