Discussion:
[Middlegen-user] two foreign keys to the same table
Alex Greif
2004-01-26 10:12:21 UTC
Permalink
hi,

In the following simple sample middlegen generates strange code.
Im a DB novice so maybe the sql code is not right, but jboss/hsqldb had
no problems with it:

CREATE TABLE "addresses" (
"address_id" INT NOT NULL,
"city" VARCHAR NOT NULL,
"street" VARCHAR NOT NULL,
PRIMARY KEY("address_id")
);

CREATE TABLE "customers" (
"customer_id" INT NOT NULL,
"first_name" VARCHAR NOT NULL,
"last_name" VARCHAR NOT NULL,
"login" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL,
"billing_address_id_fk" INT NOT NULL,
"shipping_address_id_fk" INT NOT NULL,
PRIMARY KEY("customer_id"),
FOREIGN KEY ("billing_address_id_fk") REFERENCES "addresses"("address_id"),
FOREIGN KEY ("shipping_address_id_fk") REFERENCES "addresses"("address_id")
);


In the CustomerValue.class it generates the following code where the
same field name is declared more than once:

private java.lang.Integer billingAddressIdFk;
private boolean billingAddressIdFkHasBeenSet = false;
private java.lang.Integer shippingAddressIdFk;
private boolean shippingAddressIdFkHasBeenSet = false;
private flowshop.interfaces.AddressLightValue Address; // duplicate
private boolean AddressHasBeenSet = false; // duplicate
private flowshop.interfaces.AddressLightValue Address; // duplicate
private boolean AddressHasBeenSet = false; // duplicate


has anybody has a hint whats wrong with the sql code?

I use the cvs version of middlegen with jboss 3.2.3 with hsqldb 1.7.1

chers
Alex.
Russell Simpkins
2004-01-26 10:46:51 UTC
Permalink
The duplicate definition is due to the dual foreign keys. One set of
interface values for each key. You may need to use the gui to tell
middlegen to give each fk reference unique interface names, or just
manually fix that.

-----Original Message-----
From: middlegen-user-***@lists.sourceforge.net
[mailto:middlegen-user-***@lists.sourceforge.net] On Behalf Of Alex
Greif
Sent: Saturday, January 24, 2004 10:20 AM
To: middlegen-***@lists.sourceforge.net
Subject: [Middlegen-user] two foreign keys to the same table

hi,

In the following simple sample middlegen generates strange code.
Im a DB novice so maybe the sql code is not right, but jboss/hsqldb had
no problems with it:

CREATE TABLE "addresses" (
"address_id" INT NOT NULL,
"city" VARCHAR NOT NULL,
"street" VARCHAR NOT NULL,
PRIMARY KEY("address_id")
);

CREATE TABLE "customers" (
"customer_id" INT NOT NULL,
"first_name" VARCHAR NOT NULL,
"last_name" VARCHAR NOT NULL,
"login" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL,
"billing_address_id_fk" INT NOT NULL,
"shipping_address_id_fk" INT NOT NULL,
PRIMARY KEY("customer_id"),
FOREIGN KEY ("billing_address_id_fk") REFERENCES
"addresses"("address_id"),
FOREIGN KEY ("shipping_address_id_fk") REFERENCES
"addresses"("address_id")
);


In the CustomerValue.class it generates the following code where the
same field name is declared more than once:

private java.lang.Integer billingAddressIdFk;
private boolean billingAddressIdFkHasBeenSet = false;
private java.lang.Integer shippingAddressIdFk;
private boolean shippingAddressIdFkHasBeenSet = false;
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate


has anybody has a hint whats wrong with the sql code?

I use the cvs version of middlegen with jboss 3.2.3 with hsqldb 1.7.1

chers
Alex.


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
Timothy Peter Cockle
2004-01-28 04:02:50 UTC
Permalink
Also FK's can not be defined as NOT NULL.
Post by Russell Simpkins
The duplicate definition is due to the dual foreign keys. One set of
interface values for each key. You may need to use the gui to tell
middlegen to give each fk reference unique interface names, or just
manually fix that.
-----Original Message-----
Greif
Sent: Saturday, January 24, 2004 10:20 AM
Subject: [Middlegen-user] two foreign keys to the same table
hi,
In the following simple sample middlegen generates strange code.
Im a DB novice so maybe the sql code is not right, but jboss/hsqldb had
CREATE TABLE "addresses" (
"address_id" INT NOT NULL,
"city" VARCHAR NOT NULL,
"street" VARCHAR NOT NULL,
PRIMARY KEY("address_id")
);
CREATE TABLE "customers" (
"customer_id" INT NOT NULL,
"first_name" VARCHAR NOT NULL,
"last_name" VARCHAR NOT NULL,
"login" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL,
"billing_address_id_fk" INT NOT NULL,
"shipping_address_id_fk" INT NOT NULL,
PRIMARY KEY("customer_id"),
FOREIGN KEY ("billing_address_id_fk") REFERENCES
"addresses"("address_id"),
FOREIGN KEY ("shipping_address_id_fk") REFERENCES
"addresses"("address_id")
);
In the CustomerValue.class it generates the following code where the
private java.lang.Integer billingAddressIdFk;
private boolean billingAddressIdFkHasBeenSet = false;
private java.lang.Integer shippingAddressIdFk;
private boolean shippingAddressIdFkHasBeenSet = false;
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate
has anybody has a hint whats wrong with the sql code?
I use the cvs version of middlegen with jboss 3.2.3 with hsqldb 1.7.1
chers
Alex.
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Timothy Peter Cockle
2004-01-28 07:21:16 UTC
Permalink
BTW this is because the FK elements are not added on the call to create
but with postCreate.
Post by Timothy Peter Cockle
Also FK's can not be defined as NOT NULL.
Post by Russell Simpkins
The duplicate definition is due to the dual foreign keys. One set of
interface values for each key. You may need to use the gui to tell
middlegen to give each fk reference unique interface names, or just
manually fix that.
-----Original Message-----
Greif
Sent: Saturday, January 24, 2004 10:20 AM
Subject: [Middlegen-user] two foreign keys to the same table
hi,
In the following simple sample middlegen generates strange code.
Im a DB novice so maybe the sql code is not right, but jboss/hsqldb had
CREATE TABLE "addresses" (
"address_id" INT NOT NULL,
"city" VARCHAR NOT NULL,
"street" VARCHAR NOT NULL,
PRIMARY KEY("address_id")
);
CREATE TABLE "customers" (
"customer_id" INT NOT NULL,
"first_name" VARCHAR NOT NULL,
"last_name" VARCHAR NOT NULL,
"login" VARCHAR NOT NULL,
"password" VARCHAR NOT NULL,
"billing_address_id_fk" INT NOT NULL,
"shipping_address_id_fk" INT NOT NULL,
PRIMARY KEY("customer_id"),
FOREIGN KEY ("billing_address_id_fk") REFERENCES
"addresses"("address_id"),
FOREIGN KEY ("shipping_address_id_fk") REFERENCES
"addresses"("address_id")
);
In the CustomerValue.class it generates the following code where the
private java.lang.Integer billingAddressIdFk;
private boolean billingAddressIdFkHasBeenSet = false;
private java.lang.Integer shippingAddressIdFk;
private boolean shippingAddressIdFkHasBeenSet = false;
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate
private flowshop.interfaces.AddressLightValue Address; //
duplicate
private boolean AddressHasBeenSet = false; // duplicate
has anybody has a hint whats wrong with the sql code?
I use the cvs version of middlegen with jboss 3.2.3 with hsqldb 1.7.1
chers
Alex.
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
middlegen-user mailing list
https://lists.sourceforge.net/lists/listinfo/middlegen-user
Loading...