• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[JPA] Benefit of @JoinColumn on @ManyToOne

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any benefit of specifying a join column for a many-to-one relationship in JPA? Looking the generated tables you get the same results either way.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You specify the @JoinColumn to set the foreign key column name for the relationship. Otherwise a default name will be given for the foreign key column. If you are mapping to an existing database schema you will typically require setting the @JoinColumn, otherwise the defaults are probably fine.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic