java - 了解 Hibernate 部分刷新行为

标签 java mysql hibernate

在我的 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/

相关文章:

java - Hibernate 单表数据库的可行性

java - 生成的查询包含架构和目录名称

java stax 获取内部节点的字符串

Java Regex matches() 返回 false 但在浏览器中有效

java - Java7 的多异常 catch 子句是否使用鸭子类型?

php - 排序不适用于 PHP SQL ORDER BY

mysql - 如何创建触发器来更新从另一个更新表计算的列

java - CipherInputStream 中的 skip 方法

MySQL批处理和连接: is it possible using SQL file injection?

java - 如何在JPA中正确实现相关实体的乐观锁