## 5.5.2.9 Custom Cascade Behaviour

As describes in the section on cascading updates, the primary mechanism to control the way updates and deletes are cascading from one association to another is the belongsTo static property.

However, the ORM DSL gives you complete access to Hibernate's transitive persistence capabilities via the `cascade` attribute.

Valid settings for the cascade attribute include:

- create - cascades creation of new records from one association to another
- merge - merges the state of a detached association
- save-update - cascades only saves and updates to an association
- delete - cascades only deletes to an association
- lock - useful if a pessimistic lock should be cascaded to its associations
- refresh - cascades refreshes to an association
- evict - cascades evictions (equivalent to discard() in GORM) to associations if set
- all - cascade ALL operations to associations
- delete-orphan - Applies only to one-to-many associations and indicates that when a child is removed from an association then it should be automatically deleted

> It is advisable to read the section in the Hibernate documentation on transitive persistence to obtain a better understanding of the different cascade styles and recommendation for their usage

To specific the cascade attribute simply define one or many (comma-separated) of the aforementioned settings as its value:

    class Person {
      String firstName
      static hasMany = [addresses:Address]
      static mapping = {
          addresses cascade:"all-delete-orphan"
      }
    }
    class Address {
      String street
      String postCode
    }