我将带有hibernate的ehcache与spring数据一起使用。作为连接池,我使用hikaricp。
以下是一个查询的hibernate日志:
2016-04-24 17:03:16 INFO [qtp603358340-29] StatisticalLoggingSessionEventListener: 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;
89979 nanoseconds spent performing 41 L2C hits;
3214 nanoseconds spent performing 1 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)
}
2016-04-24 17:03:16 INFO [qtp603358340-29] StatisticalLoggingSessionEventListener: Session Metrics {
116282684 nanoseconds spent acquiring 1 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)
}
正如你所看到的l2缓存工作得很好,但是hibernate无论如何都会获得连接,这需要太长时间,因为DB很好......慢而且糟糕。不要考虑DB,只是告诉我,为什么在l2点击后,hibernate试图获取连接?有可能迫使他不要这样做吗?我的连接池也可能有问题吗?