cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Anderson" <>
Subject RE: Handling of database NULL - default value column to modeler?
Date Wed, 20 Aug 2008 16:49:06 GMT
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: [] On Behalf Of Øyvind Harboe
Sent: Wednesday, August 20, 2008 5:47 AM
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
ARM7 ARM9 XScale Cortex
JTAG debugger and flash programmer

View raw message