• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Annotation

 
Amandeep Singh
Ranch Hand
Posts: 850
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know exactly what you mean. Can you refer exactly the book (or ??)
 
Karnati Sudhakar
Ranch Hand
Posts: 270
Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you refer exactly the book (or ??)


I am referring to EJB3 in Action.

Regards
Sudhakar
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Amandeep can you be a little bit more precise (you know page) a e text insert from book will be pretty helpful.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic