tags:

views:

394

answers:

1

I'm a bit confused about the 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.

+2  A: 

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:

Jean Barmash
I'd skimmed that before but it hadn't really registered. In what cases would I want to store the parent's key in the child as opposed to vice versa?
Visionary Software Solutions