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 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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "@primarykeyjoincolumn for OnetoMany and ManytoOne?" Watch "@primarykeyjoincolumn for OnetoMany and ManytoOne?" New topic
Author

@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.

Regards
Sudhakar


Regards
Sudhakar
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%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @primarykeyjoincolumn for OnetoMany and ManytoOne?
 
Similar Threads
CollectionOfElements
Problems in JPA with a Collection of Dates
CollectionOfElemetns
ManyToMany & fields of association table
Possible to find relationship