grails - GORM Gotchas Part 2 by Peter Ledbrook -
i trying understand meaning of phrase in gorm gotchas part 2:
the advantage of syntax can define multiple cascading relationships.
does mean multiple cascading relationships between location , domain classes other author author or mean transitive (chaining) cascading relationships between location , author , author , other domain class? can provide example of syntax of these multiple cascading relationships? think make clearer. thank you.
i provide example our current application: have user
s , home
s. home has many residents (instances of user
) can live in multiple home
s.
a user can register webhook
events happening on home. if user gets deleted (his account removed), want remove web hooks, registered user. if home gets deleted users remain, web hooks of home should removed (since there not more events happening deleted home).
so class webhook
this:
class webhook { string url static belongsto = [home: home, registrator: user] }
the belongsto
relation in case map, adds home
, registrator
properties on webhook
class. if not need references want have cascading behavior, can use list , define belongsto
relation this:
static belongsto = [home, user]
both ways guarantee web hook gets deleted when either home or user associated deleted.
Comments
Post a Comment