This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Ranch Hand
Posts: 106
Hibernate Python MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

or

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

http://download.oracle.com/javaee/5/api/javax/persistence/PrimaryKeyJoinColumn.html
http://download.oracle.com/javaee/6/api/javax/persistence/PrimaryKeyJoinColumn.html

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

Karsten
 
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

See,
http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Primary_Keys_through_OneToOne_and_ManyToOne_Relationships

and,
http://en.wikibooks.org/wiki/Java_Persistence/OneToOne#Target_Foreign_Keys.2C_Primary_Key_Join_Columns.2C_Cascade_Primary_Keys

 
Karsten Wutzke
Ranch Hand
Posts: 106
Hibernate Python MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for helping on this! I'll have to file a few bug reports now.

Karsten
 
You got style baby! More than this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic