Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java hibernate查询在堆转储中的作用_Java_Hibernate_Jakarta Ee_Heap_Jprofiler - Fatal编程技术网

Java hibernate查询在堆转储中的作用

Java hibernate查询在堆转储中的作用,java,hibernate,jakarta-ee,heap,jprofiler,Java,Hibernate,Jakarta Ee,Heap,Jprofiler,我正在使用我的应用程序来分析高CPU使用率。用户登录时,CPU使用率为100%(在服务器上)。于是开始分析我的应用程序 下面是我在堆转储中找到的查询字符串。不仅这4个查询,转储中还有数百个类似的查询 java.lang.String (0x3262b1) ["/* load com.v4common.shared.beans.transaction.ControlTransaction */ select controltra0_.id as id47_48_, controltra0_.for

我正在使用我的应用程序来分析高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 %)
我只是登录到系统中,我根本没有碰这些豆子,但我仍然能够在垃圾堆中看到它们

你知道为什么垃圾堆里有这些绳子吗


或者那条线是什么意思

这是正常的,这些是在服务器启动时准备的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 
以注释
one-to-many
one-to-one
开头的查询用于延迟加载等。JPQL/HQL中的命名查询也会在服务器启动时编译为SQL查询,注释会标识是哪个命名查询发起了SQL查询

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


因此,在用户第一次登录时,这些查询在堆中是很正常的。

您的实体上是否有这些查询作为
@namedquerys
(或
@NamedQuery
)存在


Hibernate可能在服务器启动时将命名查询加载到其缓存中。它们肯定会在启动时被解析以检查语法等。

AFAIK这是由hibernate查询缓存造成的,但不知道如何使hibernate不存储这些查询。@Luigimendoza谢谢。但我还没有发出这些查询,甚至一次也没有。还是那些被缓存了??或者在应用程序启动hibernate时执行此操作???你能告诉我这个吗??我不知道。我们可以通过一些配置来禁用查询缓存吗?你确定在部署应用程序时不加载初始数据吗?除非我们明确设置,否则hibernate不会缓存查询。我强烈怀疑,以前的电话中没有GCed。@Nambari我已经尝试禁用此功能,但也没有起作用……没有。我没有任何疑问。我正在使用criteriaapi。