File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes I need a bit of explanation about bidirectional relation between two entity beans. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "I need a bit of explanation about bidirectional relation between two entity beans." Watch "I need a bit of explanation about bidirectional relation between two entity beans." New topic
Author

I need a bit of explanation about bidirectional relation between two entity beans.

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 550
Hi
thank you for reading my post.
Can some one please tell me what could be possible tables and table relation for following code?

House.java:




Student.java




thanks
Tong Wang
Ranch Hand

Joined: Jun 20, 2005
Posts: 44
I assume you are asking about the SQL table structure for storing these entity beans. As for the SQL part, there is no difference between bidirectional and unidirectional relations. You will have the same primary key/foreign key constraint in the tables, or you will have the same join table.

In other words, you will have primary keys in both tables and a foreign key in the many-side table that refers to the primary key of the one-side table.

Or, you will have a join table with two foreign key columns: one referring the primary key of the one-side table, the other referring the primary key of the many-side table.

Hope this helps.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

House table has a house_id PK

Student table has a student_id PK and a house_id Foreign Key (FK)

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I need a bit of explanation about bidirectional relation between two entity beans.
 
Similar Threads
Java Rule Round Up: Question 80
EJB-QL Question
Association ,Composition, Aggregation
java
WA #1.....word association