File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Using @JoinColumn VS not using @JoinColumn Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Using @JoinColumn VS not using @JoinColumn" Watch "Using @JoinColumn VS not using @JoinColumn" New topic

Using @JoinColumn VS not using @JoinColumn

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 608

Hi all,

I would just like to clarify the difference between the following 2 code samples from EJB3 in Action:
First code sample:

2nd Code Sample:

The 2nd code sample is missing the @JoinColumn.

So in the 1st case it would be possible to use the foreign key in the User table to locate the relevant Bid/s using SQL.

Whereas the 2nd case wouldn't have a foreign key BUT it would still be possible to access the relevant Bid/s through the User object's reference to a collection of Bids albeit only via JPQL this time?

===>SCJP 1.5(72%)<===
I agree. Here's the link:
subject: Using @JoinColumn VS not using @JoinColumn
It's not a secret anymore!