(Quick Reference)

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 accessor methods ("getters") that are helper methods but get confused as being persistence-related.

Examples

class Author {
   String name
   String getUpperCaseName() { name.toUpperCase() }

   static transients = ['upperCaseName']
}

Here we have an accessor that takes the name and converts it to uppercase. It doesn’t make sense to persist this derived value, so we mark it as transient adding its JavaBean property name to the transients list.

As of Grails 2.0 if there is only a getter or only a setter method, you don’t need to declare the property name of the method in the transients list. Only typed fields and get/set pairs that form a property but shouldn’t be persisted need to go in the transients list.