aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes JPA Annotation 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 "JPA Annotation" Watch "JPA Annotation" New topic
Author

JPA Annotation

Amandeep Singh
Ranch Hand

Joined: Jul 17, 2008
Posts: 844
I would like to know clear differnce between @JoinColumn
and @PrimaryKeyColumn annotations. Although i have do examples from EJB3 in Action, but it looks like they are doing the same work.

Please advise. :roll:


SCJP 1.4, SCWCD 5, SCBCD 5, OCPJWSD 5,SCEA-1, Started Assignment Part 2
My blog- http://rkydesigns.blogspot.com
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Hi Amandeep,

When you refer the @PrimaryKeyColumn you mean PrimaryKeyJoinColumn ? if yes the the answer is hidden in the annotation name.
The JoinColumn is used to join a column from a source table with an other (table) destination column where the source table column (to join) is a foriner key (in EJB in Action this explication is on page 274). This means you just join a column - not a special column like the primary key column.
The PrimaryKeyJoinColumn does what the JoinColumn does not do it joins a column from a source table on other destination (table) column where the source table column (to join) is a primary key column. This means you join a certain kind of column the id column.

But don't worry I also read and re-read (and re-read,....) until a really understand what is going on. The "EJB in Action" explanations are pretty clear but you need also a little bit Relational Database way of thinking -> you must be able to picture in your head how the primary key- foreigner key relation are working after this everything is quite easy.

Regards,
M


SCJP, SCJD, SCWCD, OCPJBCD
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

When i read the book again and again i found one difference i.e. @JoinColumn introduces one extra column where as @PrimaryKeyJoinColumn does not.

Regards
Sudhakar


Regards
Sudhakar
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

I don't know exactly what you mean. Can you refer exactly the book (or ??)
Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Can you refer exactly the book (or ??)


I am referring to EJB3 in Action.

Regards
Sudhakar
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 916

Amandeep can you be a little bit more precise (you know page) a e text insert from book will be pretty helpful.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPA Annotation