在我的 java 应用程序(使用 Hibernate)中,我从 Hibernate Metrics 中看到以下详细信息
org.hibernate.engine.internal.StatisticalLoggingSessionEventListener Session Metrics {
46195 nanoseconds spent acquiring 1 JDBC connections;
0 nanoseconds spent releasing 0 JDBC connections;
148413278 nanoseconds spent preparing 1300 JDBC statements;
203780356679 nanoseconds spent executing 1300 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;
414686772 nanoseconds spent executing 2 flushes (flushing a total of 1376 entities and 0 collections);
325171056 nanoseconds spent executing 650 partial-flushes (flushing a total of 107052 entities and 107052 collections)
典型的代码流程是使用源表中的数据为一些目标表准备数据:
- 从多个源表[4到5个表]中选择记录,
- 做一些处理,为最终目标表 [1-3 个表] 准备数据。在处理过程中的任何时候源表实体都没有变化。也没有使用 native 查询。
- 在最终表中保留记录。
我想获得一些关于寻找什么以确定可能导致部分刷新的原因的指示。
谢谢
最佳答案
您必须在您打算保留的方法中指明@Transactional 注释。
关于java - 了解 Hibernate 部分刷新行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27272416/