This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Foreign key & EJB3" Watch "Foreign key & EJB3" New topic
Author

Foreign key & EJB3

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

Hi,

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%)<===
==>SCWCD1.5(76%)<===
Yair Ivan
Greenhorn

Joined: Jul 13, 2008
Posts: 15

Hi Duran:

Reviews:

http://www.coderanch.com/t/163738/EJB-Certification-SCBCD/certification/EJB-Action-JPA

By.


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

Joined: Nov 09, 2008
Posts: 598

Thanks that explained it nicely
 
Don't get me started about those stupid light bulbs.
 
subject: Foreign key & EJB3
 
Similar Threads
One-to-one and cascade
hibernate 1:M relationships & cascade
Java Persistence API Entities Enthuware Wrong Answer
Heap exception while loading complete table data from database
@ManyToMany remove records from join rows