我有一个Java Spring Boot应用程序,其中包含与以下异常相关的以下实体
SProduct
@Entity
@Table(
name = "product",
indexes = @Index(
name = "idx_asin",
columnList = "asin",
unique = true
)
)
public class SProduct implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "asin", unique = false, nullable = false, length = 10)
private String asin;
@Column(name = "rootcategory")
private Long rootcategory;
@Column(name = "imageCSV", unique = false, nullable = true, length = 350)
private String imagesCSV;
@Column(name = "title", unique = false, nullable = true, length = 350)
private String title;
private Date created;
@OneToMany(fetch = FetchType.EAGER, mappedBy = "mainProduct", cascade = CascadeType.ALL)
private Set fbts;
@OneToOne(fetch = FetchType.EAGER, mappedBy = "downloadProductId", cascade = CascadeType.ALL)
private Download download;FBT
@Entity
@Table(
name = "fbt",
uniqueConstraints={@UniqueConstraint(columnNames = {"main_product_id" , "collection"})},
indexes = {@Index(
name = "idx_main_product_id",
columnList = "main_product_id",
unique = false),
@Index(
name = "idx_product_fbt1id",
columnList = "product_fbt1_id",
unique = false),
@Index(
name = "idx_product_fbt2id",
columnList = "product_fbt2_id",
unique = false)
}
)
public class FBT implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@ManyToOne
@JoinColumn(name = "main_product_id")
private SProduct mainProduct;
@ManyToOne
@JoinColumn(name = "product_fbt1_id")
private SProduct sproductFbt1;
@ManyToOne
@JoinColumn(name = "product_fbt2_id")
private SProduct sproductFbt2;
@Column(name = "bsr", nullable = false)
private int bsr;
private Date collection;我的fbt存储库中有以下查询
FBT findByMainProductAndCollection(SProduct mainProduct,Date collection);当mainProduct和集合的数据存在于数据库中时,导致以下消息输出异常,否则返回null。
HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@69b7fcfc
HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@47c40535
HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@5b0cd175
HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@f67e2cc
HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@5961afc0
HHH000160: On CollectionLoadContext#cleanup, localLoadingCollectionKeys contained [1] entries
HHH000100: Fail-safe cleanup (collections) :我决定放弃上面的内容,编写一个@query来计数,因为我只需要确定数据是否存在,这样就避免了这个问题,这个问题让我认为我应该把所有的代码都改成使用@query。
@Query("select count(*) as count from FBT where main_product_id = :id and collection= :collection")
int countByMainProductIdAndCollection(@Param("id") long id, @Param("collection") Date collection);尽管当一个SProduct的数据库中已经存在该产品时,这似乎也会随机地发生在更新到该产品的数据库中时。
SProductRepo.saveAndFlush(s);我说是随机的,因为运行相同代码的11个应用程序以随机的间隔退出,并显示上述消息。代码不会产生任何异常,10000的成功数据库更新都使用导致失败的相同代码。代码在尝试更新它以前工作过的数据库时停止。
""2018-12-28 00:56:06 [KeepaAPI-RetryScheduler] WARN org.hibernate.engine.loading.internal.LoadContexts - HHH000100: Fail-safe cleanup (collections) : org.hibernate.eng
ine.loading.internal.CollectionLoadContext@5c414639
""2018-12-28 00:56:06 [KeepaAPI-RetryScheduler] WARN org.hibernate.engine.loading.internal.CollectionLoadContext - HHH000160: On CollectionLoadContext#cleanup, localLoa
dingCollectionKeys contained [1] entries
""2018-12-28 00:56:06 [KeepaAPI-RetryScheduler] WARN org.hibernate.engine.loading.internal.LoadContexts - HHH000100: Fail-safe cleanup (collections) : org.hibernate.eng
ine.loading.internal.CollectionLoadContext@5595c065
""2018-12-28 00:56:06 [KeepaAPI-RetryScheduler] WARN org.hibernate.engine.loading.internal.CollectionLoadContext - HHH000160: On CollectionLoadContext#cleanup, localLoa
dingCollectionKeys contained [1] entries
""2018-12-28 00:56:06 [KeepaAPI-RetryScheduler] WARN org.hibernate.engine.loading.internal.LoadContexts - HHH000100: Fail-safe cleanup (collections) : org.hibernate.eng
ine.loading.internal.CollectionLoadContext@2956fe24Additionally the SProduct findByAsin(String asin) query cause the same problem however the query in the database works perfectly and this used to work in spring boot.
mysql> select * from product where asin="B004FXJOQO";
| id | asin | created | imagecsv | rootcategory | title | 9 | B004FXJOQO | 2018-08-04 | 41T0ZwTvSSL.jpg,61V90AZKbGL.jpg,51AdEGCTZqL.jpg,51LDnCYfR0L.jpg,71bbIw43PjL.jpg | 228013 | Dual Voltage Tester, Non Contact Tester for High and Low Voltage with 3-m Drop Protection Klein Tools NCVT-2 |
1 row in set (0.00 sec)What I would like to know is what are the general reasons this kind of messages get generated?
Why do they stop my application despite try catch statements around my insertion statements that are the last executed statements in my code?
Are there log debugging settings useful to determine the exact reason for why the messages are generated?
Is there a way to turn off or control this functionality?
Pom
org.springframework.boot
spring-boot-starter-parent
2.1.1.RELEASE
UTF-8
UTF-8
1.8
2.10
true
Keepa
Keepa Repository
https://keepa.com/maven/
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter
org.springframework.boot
spring-boot-starter-logging
org.springframework.boot
spring-boot-starter-log4j2
org.springframework.boot
spring-boot-devtools
runtime
org.springframework.boot
spring-boot-starter-integration
javax.mail
mail
1.4.7
commons-io
commons-io
2.6
org.apache.commons
commons-compress
1.18
com.google.api-client
google-api-client
1.22.0
com.google.oauth-client
google-oauth-client-jetty
1.22.0
com.google.apis
google-api-services-oauth2
v1-rev120-1.22.0
com.google.oauth-client
google-oauth-client-java6
1.22.0
com.google.oauth-client
google-oauth-client
1.22.0
com.google.apis
google-api-services-gmail
v1-rev48-1.22.0
org.codehaus.mojo
exec-maven-plugin
1.5.0
org.slf4j
slf4j-nop
com.jcraft
jsch
0.1.54
com.myjeeva.digitalocean
digitalocean-api-client
2.16
com.google.code.gson
gson
com.keepa.api
backend
LATEST
org.jdeferred
jdeferred-core
1.2.6
com.google.guava
guava
22.0
mysql
mysql-connector-java
runtime
org.springframework.boot
spring-boot-maven-pluginI increased the memory from 1gb to 2gb however the memory is only 30% of what is available.
Any thoughts as to what the issue is?
Regards Conteh
发布于 2019-01-04 04:10:35
你能试一下吗?@Fetch(value = SELECT)
@OneToMany(fetch = FetchType.EAGER, mappedBy = "mainProduct", cascade = CascadeType.ALL)
@Fetch(value=FetchMode.SELECT)
private Set fbts;发布于 2019-07-19 18:55:11
在我的例子中,这是因为实体之间递归地调用彼此的哈希代码,如果您使用lombock删除它,并在两个哈希代码的方法上将其设为调试器的yourself.Put断点。你会发现他们在互相打电话。例如,从第一个实体的hashcode方法中删除第二个实体的链接。
发布于 2019-01-03 20:35:17
首先,它是由处理的Hibernate错误org.hibernate.engine和Spring Boot无关。
如果您正在获取大量数据,例如使用HQL查询的数万个实体,则可能会发生这种情况。
如果您映射了一个具有许多子实体的一对多关联,并且由于双向映射,结果集将无限复制,也可能出现这种情况。
有关高性能JPA提示,请参阅下面的链接。https://vladmihalcea.com/14-high-performance-java-persistence-tips/
https://stackoverflow.com/questions/53540056
复制相似问题