hibernate查询在堆转储中的作用

Sur*_*tta 8 java heap hibernate jprofiler java-ee

我正在我的应用程序进行JProfiling以分析高CPU使用率.用户登录时CPU使用率为100%(在服务器上).所以开始分析我的应用程序.

我在堆转储中找到的以下查询字符串.不仅这4个查询,转储中有数百个这样的查询.

java.lang.String (0x3262b1) ["/* load com.v4common.shared.beans.transaction.ControlTransaction */ select controltra0_.id as id47_48_, controltra0_.form_transaction_id as form2_47_48_, controltra0_.string_value as string3_47_48_, c"]     129 kB (0 %)
java.lang.String (0x310b2f) ["/* load com.v4common.shared.beans.transaction.ReportTransaction */ select reporttran0_.id as id158_45_, reporttran0_.report_id as report2_158_45_, reporttran0_.norm_id as norm3_158_45_, reporttran0_.d"]     124 kB (0 %)
java.lang.String (0x312222) ["/* load com.v4common.shared.beans.transaction.ReportItemTransaction */ select reportitem0_.id as id160_41_, reportitem0_.report_structure as report2_160_41_, reportitem0_.grid_row_criteria as grid3_16"]     110 kB (0 %)
java.lang.String (0x30c104) ["/* load com.v4common.shared.beans.Reports.EsenderCSReport */ select esendercsr0_.id as id117_36_, esendercsr0_.name as name117_36_, esendercsr0_.report_type as report3_117_36_, esendercsr0_.is_show_pr"]     94,248 bytes (0 %)
java.lang.String (0x30d1dc) ["/* load com.v4common.shared.beans.Reports.ReportStructure */ select reportstru0_.id as id120_35_, reportstru0_.name as name120_35_, reportstru0_.xml as xml120_35_, reportstru0_.esender_format as esend"]     90,736 bytes (0 %)
Run Code Online (Sandbox Code Playgroud)

我刚刚登录系统,我根本没碰到豆子,我仍然可以在转储中看到它们.

任何想法为什么这些字符串在转储中?

或者这条线甚至意味着什么?

Ang*_*ity 5

这是正常的,这些是在服务器启动时准备的Hibernate预先准备的查询.

ControlTransaction课堂为例.Hibernate已经知道可能需要查询来按ID选择实体,删除它们等等.

因此它预先生成一系列SQL预处理语句来执行这些操作.每个查询开头的注释表明它们生成的原因.

例如,生成此查询以通过Id加载ControlTransaction:

/* load com.v4common.shared.beans.transaction.ControlTransaction */ 
select controltra0_.id as id47_48_, controltra0_.form_transaction_id as form2_47_48_, controltra0_.string_value as string3_47_48_, c 
Run Code Online (Sandbox Code Playgroud)

one-to-many或的注释开头的查询one-to-one用于延迟加载等.在JPQL/HQL中的命名查询也在服务器启动时编译为SQL查询,注释标识哪个命名查询发起了SQL查询.

根据使用的映射注释,每个实体都会产生其中几个查询.

因此,在用户首次登录时堆中存在这些查询通常是正常的.