Wednesday, 15 February 2012

grails - One-to-many relationship not working as expected -



grails - One-to-many relationship not working as expected -

i'm having problems getting 1 many relationship in grails working properly. have person instance , person has relationships other persons. relationship defined in relationship object. relevant code follows.

class person { static hasmany = [relationships:relationship] string name } class relationship { person relationshipto // enum containing married, living together, parent etc. relationshiptype typeofrelationship }

now want 1 many reference relationship persisted happens in grails seems think relationshipto instance refering person has relationship else, , not other person. person has reference relationship, , relationship has type , reference person whom have relationship with. i'm not able alter domain model this. there way of accomplishing want?

what happening if utilize generated views , controllers relationship , seek create relationship type , person refering to, type persisted , person ignored. when seek add together person in persons edit or create page, relationshipto properties of relationships add together saved id of person.

hopefully wrote understandable.

finally got working.

had add together static mappedby =[relationship: 'belongsto'] person , static belongsto = [belongsto: person].

not how wanted works , ok compromise

grails

No comments:

Post a Comment