No, I left fkcmp="true".  Without that the struts won't compile.  Anyway as
you said, that wouldn't help about the keys being set to null.

It seems like this would be a problem intrinsic to all J2EE implementations,
since:

a) The J2EE container doesn't know the FK information until ejbPostCreate is
called, and
b) the INSERT statement happens before ejbPostCreate, therefore it *has* to
insert NULL for the foreign keys, violating the NOT NULL constraint so
common on foreign keys.

Since Sun obviously thought this issue out, there is probably an error in my
logic above.  Can anyone see it?  Is anyone else having this problem?

Thanks,

Russell

----- Original Message -----
From: "Eivind Waaler" <[EMAIL PROTECTED]>
To: "Russell Black" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, November 16, 2002 8:21 AM
Subject: Re: [Middlegen-user] CMR in ejbPostCreate and NOT NULL foreign keys


> Hmm, according to the SQL you're printing out there the two foreign keys
> are being set twice in the same statement. Are you using the
> fkcmp="false" attribute in your cmp20 plugin? Read the documentation about
> this attribute here:
>
> http://boss.bekk.no/boss/middlegen/plugins/cmp20.html#fkcmp
>
> I guess that wouldn't help about the keys being set to null, weird we
> haven't seen this error before though. I'll look into it on my example
> running on weblogic..
>
> Regards
> .eivind
>
> On Fri, 15 Nov 2002, Russell Black wrote:
>
> > I know the spec says that CMR fields should be set in the post-create
method, but it causes a problem when your table has a NOT NULL constraint on
the foreign key (CMR) column.  Incidentally the airlines example suffers
from this problem.  I believe the issue is this: consider the following
table:
> >
> > CREATE TABLE "reservations"(
> >  "reservation_id" INT NOT NULL,
> >  "person_id_fk" INT NOT NULL,
> >  "flight_id_fk" INT NOT NULL,
> >  "comment" VARCHAR,
> >  PRIMARY KEY ("reservation_id","person_id_fk","flight_id_fk"),
> >  FOREIGN KEY ("person_id_fk") REFERENCES "persons"("person_id"),
> >  FOREIGN KEY ("flight_id_fk") REFERENCES "flights"("flight_id")
> > );
> >
> > ejbCreate is called, and it sets the CMP fields ONLY, and it tries to do
the following SQL (copied from my JBOSS console)
> >
> > INSERT INTO reservation (reservation_id, person_id_fk, flight_id_fk,
comment, flight_id_fk, person_id_fk) VALUES (5, NULL, NULL, 'A comment',
NULL, NULL)
> >
> > Which fails because the foreign keys can't be null.  The foreign keys
aren't going to be set until the ejbPostCreate which happens AFTER the
INSERT, so it never gets that far because the INSERT fails.
> >
> > Does this imply that foreign keys can't have NOT NULL values when using
CMR?  This seems bad, because the NOT NULL constraint is there for a reason.
> >
> >
>



-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
middlegen-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/middlegen-user

Reply via email to