jQuery in Action, 3rd edition
The moose likes Object Relational Mapping and the fly likes Foreign key & EJB3 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Foreign key & EJB3" Watch "Foreign key & EJB3" New topic

Foreign key & EJB3

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 608


I'm busy trying to visualize this JPA limitation:
JPA does not support unidirectional one-to-many relationships with the foreign key on the target table

So I devised the following unidirectional one-to-many relationship:

How would I go about ensuring that there IS a foreign key on the target table?Isn't this only possible by making this bi-directional?The way I understand it...the only way that a foreign key will be stored in "CHILD" table is if the Child entity has a reference to the Father entity ie. But doing this would make the relationship bi-directional,hence the limitation wouldn't apply!How else can a foreign key be specified?

===>SCJP 1.5(72%)<===
Yair Ivan

Joined: Jul 13, 2008
Posts: 15

Hi Duran:




SCJP 6.0, SCBCD 5.0, SCDJWS 5.0
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 608

Thanks that explained it nicely
I agree. Here's the link: http://aspose.com/file-tools
subject: Foreign key & EJB3
It's not a secret anymore!