I have a small sample app here
https://github.com/jimbasilio/SpringBoot
that creates some simple data in the database and some other things I'm working on to kick the tires on spring boot (side note: so far i LOVE spring boot!!). If you clone the git repo you can visit the url:
http://127.0.0.1:8080/hello/get/1
and it'll load from the database and write the hibernate statistics to the console.
I do have a problem though, with or without configuring hibernate statistics via the application.properties file:
hibernate.generate_statistics=true
when i write the hibernate statistics out i get nothing useful. I'm fetching the statistics via:
Session session = (Session) this.entityManager.getDelegate();
session.getSessionFactory().getStatistics().logSummary();
HelloEntity entity = helloRepository.findOne(id);
entityManager.flush();
session.getSessionFactory().getStatistics().logSummary();
my SECOND log message (after flush) is below. You can see it doesn't even register sessions being opened. I'm using spring boot 1.0.1.RELEASE.
pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.1.RELEASE</version>
</parent>
log file:
2014-04-28 20:51:29.415 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000161: Logging statistics....
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000251: Start time: 1398732682476
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000242: Sessions opened: 0
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000241: Sessions closed: 0
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000266: Transactions: 0
2014-04-28 20:51:29.416 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000258: Successful transactions: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000187: Optimistic lock failures: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000105: Flushes: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000048: Connections obtained: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000253: Statements prepared: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000252: Statements closed: 0
2014-04-28 20:51:29.417 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000239: Second level cache puts: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000237: Second level cache hits: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000238: Second level cache misses: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000079: Entities loaded: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000080: Entities updated: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000078: Entities inserted: 0
2014-04-28 20:51:29.418 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000076: Entities deleted: 0
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000077: Entities fetched (minimize this): 0
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000033: Collections loaded: 0
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000036: Collections updated: 0
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000035: Collections removed: 0
2014-04-28 20:51:29.419 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000034: Collections recreated: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000032: Collections fetched (minimize this): 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000438: NaturalId cache puts: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000439: NaturalId cache hits: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000440: NaturalId cache misses: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000441: Max NaturalId query time: 0ms
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000442: NaturalId queries executed to database: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000210: Queries executed to database: 0
2014-04-28 20:51:29.420 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000215: Query cache puts: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000433: update timestamps cache puts: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000434: update timestamps cache hits: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000435: update timestamps cache misses: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000213: Query cache hits: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000214: Query cache misses: 0
2014-04-28 20:51:29.421 INFO 18044 --- [nio-8080-exec-1] o.h.s.internal.ConcurrentStatisticsImpl : HHH000173: Max query time: 0ms
Best Answer
Use
spring.jpa.properties.hibernate.generate_statistics=true
instead-ofhibernate.generate_statistics=true