This question is in two parts, first part is about clearing a list and second part is about assigning an owner to an object.
I have a one-to-many relationship between tw
Clearing Collection
approach didn't worked for me:
activePerson.locations.clear()
Just try iterate over collection with avoiding ConcurrentModificationException
by calling collect()
:
activePerson.locations.collect().each {
item.removeFromLocations(it)
}
And after that save the entity to execute SQL statement:
activePerson.save flush:true
Link to article to read more: http://spring.io/blog/2010/07/02/gorm-gotchas-part-2/