hibernate - Grails query cache is not used -
i'm trying cache following query called controller:
def approvedcount = book.countbyapproved(true, [cache: true])
i have enabled 2nd-level cache book
class, adding
static mapping = { cache true }
to book.groovy
. have following configured in datasource.groovy
hibernate { cache.use_second_level_cache = true cache.use_query_cache = true cache.region.factory_class = 'net.sf.ehcache.hibernate.ehcacheregionfactory' }
in same file i've enabled query logging adding logsql=true
in datasource
block.
every time load page, book.countbyapproved(true)
query logged, assume means results not being retrieved query cache? i'm running locally, there's no possibility cache being missed because cached query result has been invalidated (by actions of user).
i'll @ jira issue filed, looks problem dynamic finders, since hql works:
book.executequery( 'select count(*) book name=:name', [name: 'foo'], [cache: true])
as criteria query:
def count = book.createcriteria().count { eq 'name', 'foo' cache true }
Comments
Post a Comment