How to get access to the Hibernate Statistics

mainstringargs picture mainstringargs · Mar 13, 2009 · Viewed 33.4k times · Source

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?

Answer

serg picture serg · Mar 13, 2009

In your dao service you can go:

Session session = this.sessionFactory.getCurrentSession();
SessionStatistics sessionStats = session.getStatistics();
Statistics stats = this.sessionFactory.getStatistics();