The domain
method in the DSL is just an alias to make the configuration more intuitive, but it doesn't affect whether the domain class is cached, just how it's cached when it's enabled. You still need to enable caching overall with cache.use_second_level_cache = true
, and configure caching in the domain classes.
2nd-level caching in Hibernate is interface-based, and most of the real work is done by the implementation that you choose. So you need to get things started in Hibernate, and GORM uses the cache
method in the mapping
block to do this, but then you need to do the implementation-specific configuration to tune the caching, and that's where you need to work with the Ehcache API directly, or indirectly, e.g. via this DSL.