IntelliJ Java IDE
The moose likes Object Relational Mapping and the fly likes @JoinColumn V/s @JoinTable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "@JoinColumn V/s @JoinTable " Watch "@JoinColumn V/s @JoinTable " New topic
Author

@JoinColumn V/s @JoinTable

ambar patil
Ranch Hand

Joined: Nov 29, 2005
Posts: 226
I can do 1 to many unidrectional mapping
through both @JoinColumn or @JoinTable. whats the difference between two?
Shailesh Kini
Ranch Hand

Joined: Oct 17, 2001
Posts: 153
Hi Ambar,

Use @JoinColumn when the Entities have direct relationship i.e a foreign key between Entity1 and Entity2.
Use @JoinTable when you manage the relationship between Entities in another table also referred to as JoinTable.

Hope that helps


Shailesh Kini.
 
 
subject: @JoinColumn V/s @JoinTable
 
Threads others viewed
ManyToMany - Repeated column in mapping problem
Hibernate Annotation - ManyToMany within same PK on an external table
Confused with many to many,
How to name ManyToMany table and ManyToOne column?
Anyone know how to construct a one to many mapping with Hibernate / Java?
Two Laptop Bag