By default, Grails uses Hibernate with EHCache as t开发者_开发问答he second level cache. I'm still learning about how Hibernate works internally and would love to be able to introspect the caches (both EHCache and anything Hibernate does itself at 'level 1') while the application is running and executing my queries. Are there any Grails plugins or similar that will facilitate this?
Either the grails-melody plugin or the app-info plugin will allow you to see what's in the 2nd level EHCache, as well as lots of other interesting details about the internals of your app.
The hibernate 1st level cache is more transient and as far as I know, there isn't any way to examine it.
You can set you logging level for 'net.sf.ehcache.hibernate' to either info or debug in 'config.groovy'. This should give you plenty of information.
Installing JXM Plugin (http://www.grails.org/plugin/jmx) exposes Hibernate statistics as JMX.
Additionally you may need to enable statistics gathering in DataSource.groovy
:
hibernate {
generate_statistics = true
...
}
After installing the plugin you can connect to your process using for instance jconsole
and browse the statistics.
精彩评论