gpt4 book ai didi

java - Spring 启动中的 hibernate 统计信息不起作用?

转载 作者:IT老高 更新时间:2023-10-28 13:53:14 33 4
gpt4 key购买 nike

我在这里有一个小示例应用程序

https://github.com/jimbasilio/SpringBoot

这会在数据库中创建一些简单的数据,以及我正在做的一些其他事情,以便在 Spring Boot 上踢轮胎(旁注:到目前为止,我喜欢 Spring Boot !!)。如果你克隆 git repo,你可以访问 url:

http://127.0.0.1:8080/hello/get/1

它会从数据库加载并将 hibernate 统计信息写入控制台。

我确实有一个问题,无论是否通过 application.properties 文件配置 hibernate 统计信息:

hibernate.generate_statistics=true

当我写出 hibernate 统计信息时,我没有得到任何有用的信息。我正在通过以下方式获取统计信息:

Session session = (Session) this.entityManager.getDelegate();
session.getSessionFactory().getStatistics().logSummary();
HelloEntity entity = helloRepository.findOne(id);
entityManager.flush();
session.getSessionFactory().getStatistics().logSummary();

我的第二条日志消息(刷新​​后)如下。您可以看到它甚至没有注册正在打开的 session 。我正在使用 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>

日志文件:

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

最佳答案

使用 spring.jpa.properties.hibernate.generate_statistics=true代替
hibernate.generate_statistics=true

关于java - Spring 启动中的 hibernate 统计信息不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23353803/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com