grails hasOne vs direct member variable

前端 未结 4 943
余生分开走
余生分开走 2021-02-04 02:10

Let\'s say I have a grails domain class that looks like

class Person {
    Address address
}

I could also declare it as

class P         


        
4条回答
  •  囚心锁ツ
    2021-02-04 02:26

    If the foreign key exists on the address table, then that address can only have one person. If the foreign key is on the person table, multiple persons can have the same address.

    It's not about what way is better/worse. It's about what is the correct way to model your data.

提交回复
热议问题