Maintaining both sides of self-referential many-to-many relationship in Grails domain object?

This seems to work: class Person { static hasMany = friends: Person static mappedBy = friends: 'friends' String name String toString() { name } } and then in the BootStrap: class BootStrap { def init = { servletContext -> Person bob = new Person(name: 'bob').save() Person jaq = new Person(name: 'jaq').save() jaq. AddToFriends( bob ) println "Bob's friends: ${bob. Friends}" println "Jaq's friends: ${jaq.

Friends}" } } I get the following: Running Grails application.. Bob's friends: jaq Jaq's friends: bob.

Works a treat, thanks :=) The significant difference is changing jaq. FriendsI'm slightly surprised that they don't do the same thing; it'd be nice to prevent adding of friends on one side of the relationship only. – Alison Mar 25 '10 at 19:51.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions