wood burning stoves*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes @primarykeyjoincolumn for OnetoMany and ManytoOne? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "@primarykeyjoincolumn for OnetoMany and ManytoOne?" Watch "@primarykeyjoincolumn for OnetoMany and ManytoOne?" New topic

@primarykeyjoincolumn for OnetoMany and ManytoOne?

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Hi All,

I just want to know if we can implement OnetoMany and ManytoMany relation ships using @primarykeyJoinColumn.
In EJB in Action OnetoMany and ManytoMany are implemented using @JoinColumn annotation where as OnetoOne is implemented by using both @JoinColumn and @primarykeyJoinColumn annotations.

It would be great if anybody can post the implementation part.


Tomaszz Lewandowski
Ranch Hand

Joined: Sep 07, 2007
Posts: 30
As far as relationships are concerned, @PrimaryKeyJoinColumn can only be applied to @OneToOne relationship, as it "joins" two entities by their primary keys. That's why it wouldn't make sence for ManyToXXX relationships (because primary keys are "unique").

Regards<br />Tomasz Lewandowski<br />SCJP5 (97%) | SCWCD5 (98%)
jQuery in Action, 2nd edition
subject: @primarykeyjoincolumn for OnetoMany and ManytoOne?
Similar Threads
Possible to find relationship
ManyToMany & fields of association table
Problems in JPA with a Collection of Dates