Last active
December 16, 2015 20:10
-
-
Save ishults/10553660 to your computer and use it in GitHub Desktop.
Modified Hibernate stats controller filter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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