Hibernate Criteria and statistics
We are heavy users of the Hibernate Statistics in our application, but recently came to realize that Statistics.getQueries() does not return any Criteria queries. I realize that the method returns the HQL strings, but it also means that the Statistics are incomplete. I found a few older issues talking about this, but no resolution.
http://opensource.atlassian.com/projects/hibernate/browse/HHH-634
Also HHH-3452开发者_StackOverflow talks about this as well.
The strange thing is that the count methods like Statistics.getQueryExecutionCount() return the TOTAL number of queries including the Critieria ones. However Statistics.getQueries ignores the Criteria. Frustrating.
Has anyone else figured out a way to track execution statistics for Criteria queries?
Manually add the criteria query data using aspects; Most of the links in the internet are not reachable anymore, so I added our documentation to my blog
The issues are still open, but HHH-3452 has been updated with a reference to a AspectJ hack that goes around the issue by overriding one method from Hibernate on the fly. See http://www.olivergierke.de/wordpress/2010/09/enabling-hibernate-critera-query-statistics-with-aspectj/
精彩评论