Sounds like you want to make the field NOT NULL with a default value in the database. That would transparently do what you've described, without any reliance on Cayenne.
-----Original Message-----
From: oyvindharbo..mail.com [mailto:oyvindharboe@gmail.com] On Behalf Of Øyvind Harboe
Sent: Wednesday, August 20, 2008 5:47 AM
To: cayenne-use..ncubator.apache.org
Subject: Handling of database NULL - default value column to modeler?
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
This archive was generated by hypermail 2.0.0 : Wed Aug 20 2008 - 12:50:04 EDT