Grails 1.1 缓存策略 - 缓存关联对象

就像使用Hibernate的二级缓存来缓存实例一样,你也可以来缓存集合(关联),比如:class Person { String firstName static hasMany = [addresses:Address] static mapping = { table 'people' version false addresses column:'Address', cache:true } } class Address { String number String postCode }上面的例子中,我们在 addresses 集合启用了一个读-写缓存,你也可以使用:cache:'read-write' // or 'read-only' or 'transactional'