• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Owning Table - mappedBy

 
Anup Om
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Could someone please explain me the concept of owning table? How is foreign key related to owning table?

Thanks for your help.
 
James Sutherland
Ranch Hand
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The owning table for a foreign key, is the table that contains the foreign key column and the foreign key constraint.

A mappedBy can be used in the inverse table, to reuse the same foreign key in two directions.

In a OneToOne the foreign key can be in either the source or target table.

In a OneToMany the foreign key is always in the target table (so always uses a mappedBy, unless using a join table).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic