So, I have several objects in the domain that are in hasMany relationship with each other, as shown below
Class Car { String name SortedSet tires = [] as SortedSet static hasMany = [tires: Tire] } Class Tire { String type SortedSet screws = [] as SortedSet static hasMany = [screws: Screw] } Class Screws { String type }
Now I would like to delete the entire tree of objects offline for a certain type of car, which I can get with findByName. I know that we can make a choice for the seeker, but this is reduced by only one level. As in the example, I have 2 levels or more.
So my question is this. Is there an elegant solution to get the whole tree of objects and then use it without using grails / Hibernate, discarding another request to get the details.
I tried the following, it seems like a similar result, but hardly elegant.
Solution withCriteria
def cars = Car.withCriteria { tires { screws { join 'screws' } }
I also tried converting the whole tree to JSON and redrawing it, but this seems to be overkill. I think basically I'm trying to get the whole tree of objects offline. Any thoughts if this can be done easily or in general?
TIA
source share