Skip to content

Instantly share code, notes, and snippets.

@ishults
Last active December 16, 2015 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishults/10553660 to your computer and use it in GitHub Desktop.
Save ishults/10553660 to your computer and use it in GitHub Desktop.
Modified Hibernate stats controller filter
def sessionFactory
// ...
logHibernateStats(controller: '*', action: '*') {
before = {
Statistics stats = sessionFactory.statistics
log.info "\n### In action: $controllerName/$actionName ###"
if (!stats.statisticsEnabled) {
stats.statisticsEnabled = true
}
}
afterView = {
Statistics stats = sessionFactory.getStatistics()
log.info """
############## Hibernate Stats ##############
Action: /${controllerName}/${actionName}
Transaction Count: ${stats.transactionCount}
Flush Count: ${stats.flushCount}
Prepared Statement Count: ${stats.prepareStatementCount}
#############################################
"""
stats.clear() // We assume no one else is using stats
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment