我正在使用带有Spring API的Hibernate 5。使用apache tomcat9运行Java 8。 Mysql 5.x. 我使用getSession()。getCurrentSession()访问对象,每个请求只有一个弹簧会话。 (很高兴粘贴我的struts动作,但不确定它是否有帮助)。
我启用了stat日志记录,它会在结尾显示所有查询和会话统计信息 所以我会看到一堆查询然后这个(正确的)一个会话摘要:
2017-06-17 19:04:56,621 INFO org.hibernate.engine.internal.StatisticalLoggingSessionEventListener.end - Session Metrics {
1591683 nanoseconds spent acquiring 9 JDBC connections;
1073951 nanoseconds spent releasing 8 JDBC connections;
1173965 nanoseconds spent preparing 10 JDBC statements;
6098889 nanoseconds spent executing 10 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;
100987632 nanoseconds spent executing 7 flushes (flushing a total of 413 entities and 1445 collections);
95887194 nanoseconds spent executing 3 partial-flushes (flushing a total of 130 entities and 130 collections)
}
然而,在此之后(会话结束),它还会显示大约20-40个空会话,如下所示:
2017-06-17 19:04:56,873 INFO org.hibernate.engine.internal.StatisticalLoggingSessionEventListener.end - Session Metrics {
0 nanoseconds spent acquiring 0 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
0 nanoseconds spent preparing 0 JDBC statements;
0 nanoseconds spent executing 0 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;
0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
0 nanoseconds spent executing 0 partial-flushes (flushing a total of 0 entities and 0 collections)
}
有谁知道这是否正常?