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 users , homes. home has many residents (instances of user) can live in multiple homes.

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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -