Skip to content

Instantly share code, notes, and snippets.

@thjanssen
Last active January 9, 2017 03:49
Show Gist options
  • Save thjanssen/05c334cb48b7f0f56df155ab4e75821a to your computer and use it in GitHub Desktop.
Save thjanssen/05c334cb48b7f0f56df155ab4e75821a to your computer and use it in GitHub Desktop.
Statistics stats = sessionFactory.getStatistics();
long queryCount = stats.getQueryExecutionCount();
<persistence>
<persistence-unit name=”my-persistence-unit”>
<description>Hibernate Tips</description>
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name=”hibernate.generate_statistics” value=”true” />
</properties>
</persistence-unit>
</persistence>
16:24:55,318 INFO [org.hibernate.engine.internal.StatisticalLoggingSessionEventListener] – Session Metrics {
25659 nanoseconds spent acquiring 1 JDBC connections;
22394 nanoseconds spent releasing 1 JDBC connections;
1091216 nanoseconds spent preparing 12 JDBC statements;
11118842 nanoseconds spent executing 12 JDBC statements;
0 nanoseconds spent executing 0 JDBC batches;
0 nanoseconds spent performing 0 L2C puts;
0 nanoseconds spent performing 0 L2C hits;
0 nanoseconds spent performing 0 L2C misses;
16999942 nanoseconds spent executing 1 flushes (flushing a total of 17 entities and 17 collections);
63915 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment