transients

Purpose

Defines a list of property names that should not be persisted to the database. This is often useful if you have read-only getters that include logic.

Examples

class Author {
   String name
   String getUpperCaseName() { name.toUpperCase() }
   static transients = ['upperCaseName']
}

Here we have a getter that takes the name and converts it to upper case. In this case it doesn't make sense to persist this property, hence we mark it as transient by referring to the name using JavaBean conventions.