假如要在映射代码块中启用缺省的缓存,可以通过调用 cache 方法实现:class Person {
..
static mapping = {
table 'people'
cache true
}
}
上面的例子中将配置一个读-写(read-write)缓存包括lazy和non-lazy属性.假如你想定制这些特性,你可以如下所示:class Person {
..
static mapping = {
table 'people'
cache usage:'read-only', include:'non-lazy'
}
}