休眠 generate_statistics 将纳秒更改为秒

tek*_*ala 5 java hibernate

我使用 hibernate StatisticalLoggingSessionEventListener 来显示查询响应时间

这是日志

2016-01-20 11:10:48.841  INFO 12769 --- [http-nio-8081-exec-1] i.StatisticalLoggingSessionEventListener : Session Metrics {
  66145 nanoseconds spent acquiring 1 JDBC connections;
  0 nanoseconds spent releasing 0 JDBC connections;
  6081355 nanoseconds spent preparing 212 JDBC statements;
  14977371 nanoseconds spent executing 212 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)
}
Run Code Online (Sandbox Code Playgroud)

我们可以将纳秒值转换为秒吗?

tek*_*ala 3

不,这里不能更改是类文件https://github.com/hibernate/hibernate-orm/blob/master/hibernate-core/src/main/java/org/hibernate/engine/internal/StatisticalLoggingSessionEventListener.java

他们使用 System.nanoTime() 来获取值,并且没有额外的配置。