-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Foeign key hibernate
PostPosted: Tue Mar 01, 2011 7:03 am 
Newbie

Joined: Thu Feb 10, 2011 3:06 am
Posts: 2
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.