sir, I am using hibernate in netbeans. I have 2 following tables
CREATE TABLE persons ( P_Id int(11) NOT NULL, LastName varchar(255) NOT NULL, FirstName varchar(255) DEFAULT NULL, Address varchar(255) DEFAULT NULL, City varchar(255) DEFAULT NULL, PRIMARY KEY (P_Id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
CREATE TABLE orders ( O_Id int(11) NOT NULL, OrderNo int(11) NOT NULL, P_Id int(11) DEFAULT NULL, PRIMARY KEY (O_Id), KEY P_Id (P_Id), CONSTRAINT orders_ibfk_1 FOREIGN KEY (P_Id) REFERENCES persons (P_Id) ) ENGINE=InnoDB DEFAULT CHARSET=latin1$$
I want to insert data using set methods in orders table in feild P_Id which is foreign key. How to insert? Thank you in advance.
|