No, this is how it should work. There's a difference between "allows
null" and providing a default non-null value.
I think there are two ways you can handle this.
1) Don't put your is_active column in your model. This is probably
not realistic in your case.
2) Have your generated Entity java class set the default rather than
relying on the database to set the default. When you create the
object, set a default value for that column.
There are probably a number of reasons why having the database set the
default is a bad idea, but the primary one is that there's no way for
your java representation of the object to know what the database is
doing, and your java object and your database record will be out of
sync.
On 3/11/06, WONDER <mmmmmmmmm5..eb.de> wrote:
> It does not looks like you expliand. It is exactly as you explaind.
> No i didnt recreate the table and i wont do that.
>
> I want to have it "disallow null" in DB and "allow null" in the model.
> The default value in the DB should insert the default value.
>
> The problem is Cayenne sends "NULL" to DB.
>
> I dont think its good style to use NULL at all in Cayenne. According to
> sending NULL to db mean
> I have no way to use the defaul value feature of the DB. This is nonsence,
> isnt it?
>
> Sako.
>
> ----- Original Message -----
> From: "Mike Kienenberger" <mkienen..mail.com>
> To: <cayenne-use..bjectstyle.org>
> Sent: Saturday, March 11, 2006 10:33 PM
> Subject: Re: violates not-null constraint question.
>
>
> It looks like you have set the is_active field as "allows null" in the
> modeler, but you have set the database constraints to be "disallows
> null".
>
> Have you tried recreating the table after making the mandatory change?
> Or altering the table column to be nullable?
>
> -Mike
>
>
> On 3/11/06, WONDER <mmmmmmmmm5..eb.de> wrote:
> > Hello,
> >
> > CREATE TABLE account
> > (
> > id int4 NOT NULL,
> > username varchar(50) NOT NULL,
> > "password" varchar(100) NOT NULL,
> > is_checked bool DEFAULT false,
> >
> > ...
> >
> > In the Model i have unchecked DbEntity.Mandatory for "is_active" to
> false.
> >
> > I get this error
> >
> > ERROR: null value in column "is_active" violates not-null constraint
> >
> > Is there any way to get arround this?
> >
> > I really dont know what sence does it make to send a NULL value to the DB
> as
> >
> > ----------------------------------------------------------------
> >
> > INSERT INTO public.account (id, inactive_username, is_active, is_checked,
> > password, username) VALUES (?, ?, ?, ?, ?, ?)
> >
> > [batch bind: 47, NULL, NULL, 'false', '*****', 'XXXXX']
> >
> > ----------------------------------------------------------------
> >
> > It makes the default value technique useless, i hope there is way to
> disable
> > this.
> >
> >
> >
> > Sako.
> >
> >
> >
> >
>
>
This archive was generated by hypermail 2.0.0 : Sat Mar 11 2006 - 19:12:49 EST