开发者

Grails GORM composition or hasOne?

开发者 https://www.devze.com 2022-12-13 17:53 出处:网络
I\'m a bit confused about t开发者_JAVA技巧he differences between using the static hasOne map and composing objects in domain classes. What are the differences between the two? ie.

I'm a bit confused about t开发者_JAVA技巧he differences between using the static hasOne map and composing objects in domain classes. What are the differences between the two? ie.

class DegreeProgram {

String degreeName
Date programOfStudyApproval
static hasOne = [committee:GraduateCommittee]
}

versus

class DegreeProgram {

String degreeName
Date programOfStudyApproval
GraduateCommittee committee
}

where GraduateCommittee is another GORM domain model class.


A hasOne association should be used in the case where you want to store the foreign key reference in child table instead of the parent in a bidirectional one-to-one.

See this page for an example:

0

精彩评论

暂无评论...
验证码 换一张
取 消