2017年1月17日 星期二

mappedBy的用途

mappedBy的用途
在雙向關聯(bidirectional relationship)時,
兩方之中只有一方會是擁有者(owner),擁有者必須要負起更新,
刪除association columns等的責任,
而mappedBy attribute可以用來指出兩方關係中誰不是擁有者,
mappedBy refers to the property name of the association on the owner side。

例子:雙向的One to Many與Many to One

Reference:
  https://docs.jboss.org/hibernate/stable/annotations/reference/en/html/entity.html
  http://stackoverflow.com/questions/11938253/jpa-joincolumn-vs-mappedby

沒有留言:

張貼留言