So in my persistence.xml
I turned on hibernate.generate_statistics
.
<property name="hibernate.generate_statistics">true</property>
My question is how do I access them? Where do the statistics go?
If you enable Hibernate statistics by setting the property hibernate. generate_statistics to true, Hibernate will expose a number of useful metrics. The page "Statistics" is used to expose these metrics.
If you need to analyze performance issues, Hibernate can collect and log useful statistics about each database query and the whole session. This needs to be activated by setting the system property hibernate. generate_statistics to true and the log level for org.
The better way to activate the logging of executed SQL statements is to set the log level of the org. hibernate. SQL category to DEBUG (or the corresponding log level of your log framework).
In your dao service you can go:
Session session = this.sessionFactory.getCurrentSession(); SessionStatistics sessionStats = session.getStatistics(); Statistics stats = this.sessionFactory.getStatistics();
i would rather use Hibernate Statistics published via JMX if you use spring you can make it real easy with Hibernate Statistics MBean with Spring
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With