views:

860

answers:

3

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?

A: 

You need something like this.

duffymo
+4  A: 

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

Michael Lange
A: 

In your dao service you can go:

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