jQuery in Action, 3rd edition
The moose likes Object Relational Mapping and the fly likes JPA: is @PrimaryKeyJoinColumn(…) the same as @JoinColumn(…, insertable = ?, updatable = ?)? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPA: is @PrimaryKeyJoinColumn(…) the same as @JoinColumn(…, insertable = ?, updatable = ?)?" Watch "JPA: is @PrimaryKeyJoinColumn(…) the same as @JoinColumn(…, insertable = ?, updatable = ?)?" New topic

JPA: is @PrimaryKeyJoinColumn(…) the same as @JoinColumn(…, insertable = ?, updatable = ?)?

Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

Can anyone confirm (e.g. from the JPA spec) whether @PrimaryKeyJoinColumn(...), which doesn't have the insertable and updatable parameters, is the same as

@JoinColumn(..., insertable = false, updatable = false)


@JoinColumn(..., insertable = true, updatable = true)

when used on regular (non-inheritance) associations?

Should they be interchangable? What are the insertable and updatable properties set to? Are they set to anything at all? Note, I'm only targeting the read-only attribute that both (seem to) implement...

I'm getting rather inconsistent mapping exceptions with EclipseLink and Hibernate...

Here's the @PrimaryKeyJoinColumn JavaEE 5 + 6 Javadoc:


Quote: "... and it may be used in a OneToOne mapping in which the primary key of the referencing entity is used as a foreign key to the referenced entity."


OCJP JavaSE 6 (86%)
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Yes, the two are equivalent.

Note in JPA 2.0 you can also add an @Id to a OneToOne mapping and avoid having the duplicate basic id attribute altogether.



TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
Karsten Wutzke
Ranch Hand

Joined: Jul 20, 2010
Posts: 106

Thanks for helping on this! I'll have to file a few bug reports now.

I agree. Here's the link: http://aspose.com/file-tools
subject: JPA: is @PrimaryKeyJoinColumn(…) the same as @JoinColumn(…, insertable = ?, updatable = ?)?
It's not a secret anymore!