hibernate - grails not using cache -
hibernate - grails not using cache -
i've noticed slow downwards on site , after turning on debug 'org.hibernate.sql'
see troubles are. i've set domain class cached using....
class foo{ ... static mapping ={ cache 'read-only' } string name //<-- simple info type, no associations string description //<-- simple info type, no associations }
my hibernate config looks this...
hibernate { cache.use_second_level_cache=true cache.use_query_cache=true cache.provider_class='net.sf.ehcache.hibernate.ehcacheprovider' }
my query looks (in web flow)...
def wizardflow = { ... def flow.foos = foo.list([sort:"name", order:"asc", cache:true]) // def flow.foos = foo.findall([cache:true]) <--- same result, no caching }
i think either query cache or sec level cache stop database beingness nail log loaded with...
select ... thing thing0_ thing0_.id=? select ... thing thing0_ thing0_.id=? select ... thing thing0_ thing0_.id=? select ... thing thing0_ thing0_.id=?
can shed lite on might happening? other queries acting should!
i'm using grails 1.3.7
lastly, here ehcache.xml...
<?xml version="1.0" encoding="utf-8"?> <ehcache xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="ehcache.xsd" > <diskstore path="java.io.tmpdir"/> <cachemanagereventlistenerfactory class="" properties=""/> <defaultcache maxelementsinmemory="1000000" eternal="false" timetoidleseconds="3600" timetoliveseconds="7200" overflowtodisk="true" diskpersistent="false" /> <cache name="org.hibernate.cache.updatetimestampscache" maxelementsinmemory="10000" timetoidleseconds="300" /> <cache name="org.hibernate.cache.standardquerycache" maxelementsinmemory="10000" timetoidleseconds="300" /> </ehcache>
it looks problem had n+1 select problem. did:
import org.hibernate.fetchmode fm
...
def crit= item.createcriteria(); def itemlist = crit.listdistinct { fetchmode "subitem", fm.join cache true order("name","asc") }
you should able switch out subitem ever have associated , should help.
hibernate grails ehcache
Comments
Post a Comment