-
Mapping Primary and Foreign Keys (5 messages)
- Posted by: Doug Metcalf
- Posted on: April 10 2002 10:30 EDT
Using WSAD 4.0.2 for NT, I am trying to map a CMP entity bean to an Oracle 9i table that has two primary keys that are also foreign keys in two other tables. Is this possible? Anybody tell me how? Thanks.Threaded Messages (5)
- Mapping Primary and Foreign Keys by Neeraj Nargund on April 10 2002 11:41 EDT
- Mapping Primary and Foreign Keys by Doug Metcalf on April 10 2002 12:17 EDT
- Mapping Primary and Foreign Keys by Neeraj Nargund on April 11 2002 04:51 EDT
-
Mapping Primary and Foreign Keys by Neeraj Nargund on April 11 2002 04:59 EDT
- Mapping Primary and Foreign Keys by Doug Metcalf on April 12 2002 07:41 EDT
- Mapping Primary and Foreign Keys by Doug Metcalf on April 10 2002 12:17 EDT
-
Mapping Primary and Foreign Keys[ Go to top ]
- Posted by: Neeraj Nargund
- Posted on: April 10 2002 11:41 EDT
- in response to Doug Metcalf
two primary keys in a single table........?? or are u talking about composite primary keys -
Mapping Primary and Foreign Keys[ Go to top ]
- Posted by: Doug Metcalf
- Posted on: April 10 2002 12:17 EDT
- in response to Neeraj Nargund
Here's the DDL file used to create the table. Thanks for the response.
CREATE TABLE "ITEM_INVENTORY"
("REPLENISH_QUANTITY" INTEGER,
"MIN_THRESHOLD_LEVEL" INTEGER,
"MAX_THRESHOLD_LEVEL" INTEGER,
"AVAILABLE_QUANTITY" INTEGER,
"DAYS_TO_REPLENISH" INTEGER,
"LAST_MIN_THRESHOLD_DATE" DATE,
"INSERT_UPDATE_USERID" VARCHAR2(10),
"INSERT_UPDATE_TIMESTAMP" DATE,
"INVENTORY_LOCATION_COMP_SKEY" INTEGER NOT NULL,
"CUSTOMER_ITEM_SKEY" INTEGER NOT NULL);
ALTER TABLE "ITEM_INVENTORY"
ADD CONSTRAINT "SYS_C006899" PRIMARY KEY ("INVENTORY_LOCATION_COMP_SKEY", "CUSTOMER_ITEM_SKEY");
ALTER TABLE "ITEM_INVENTORY"
ADD CONSTRAINT "SYS_C006994" FOREIGN KEY ("INVENTORY_LOCATION_COMP_SKEY")
REFERENCES "COMPANY"("COMPANY_SKEY")
ON DELETE NO ACTION;
ALTER TABLE "ITEM_INVENTORY"
ADD CONSTRAINT "SYS_C006993" FOREIGN KEY ("CUSTOMER_ITEM_SKEY")
REFERENCES "CUSTOMER_ITEM"("CUSTOMER_ITEM_SKEY")
ON DELETE RESTRICT; -
Mapping Primary and Foreign Keys[ Go to top ]
- Posted by: Neeraj Nargund
- Posted on: April 11 2002 16:51 EDT
- in response to Doug Metcalf
Yes u can do it.
Create a Primary Key class
Class PK{
} -
Mapping Primary and Foreign Keys[ Go to top ]
- Posted by: Neeraj Nargund
- Posted on: April 11 2002 16:59 EDT
- in response to Doug Metcalf
sorry for that incomplete reply
class primarykey implements Serializable {
public variable_PK1;
public variable_PK2;
//constr
//over ride equals()
// overide hashcode()
// provide getter and setter methods to instance vaiables
}
in deployment descriptor files
<ejb-jar>
<enterprise-beans>
<entity>
<ejb-name>bean name</ejb-name>
<local-home>Home</local-home>
<local>Remote</local>
<ejb-class>Bean</ejb-class>
<prim-key-class>priamryKey</prim-key-class>
<persistence-type>Container</persistence-type>
<abstract-schema-name>..</abstract-schema-name>
<sql-table-name>..</sql-table-name>
<cmp-field>
<field-name>..</field-name>
<sql-name>..</sql-name>
</cmp-field>
...
...
...
<query>
<query-method>
<method-name>findAll</method-name>
</query-method>
<ejb-ql>....</ejb-ql>
</query>
</entity>
</enterprise-beans>
</ejb-jar>
I hope this helps.
If it does not then....
http://www.caucho.com/support/resin-interest/0110/0365.html
-
Mapping Primary and Foreign Keys[ Go to top ]
- Posted by: Doug Metcalf
- Posted on: April 12 2002 07:41 EDT
- in response to Neeraj Nargund
Thank you.