JPA休眠到很多NestedServletException问题

问题描述 投票:0回答:1

添加具有ID的职位的查询,将其添加到Employee实体中设置的职位并保存Employee实体时,出现此错误

        2020-02-29 18:01:53.689  WARN 18280 --- [nio-8083-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolved [org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.StackOverflowError]
    2020-02-29 18:01:53.692  WARN 18280 --- [nio-8083-exec-2] o.h.e.loading.internal.LoadContexts      : HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@52efd6dc<rs=HikariProxyResultSet@690866176 wrapping Result set representing update count of 2>
    2020-02-29 18:01:53.692  WARN 18280 --- [nio-8083-exec-2] o.h.e.loading.internal.LoadContexts      : HHH000100: Fail-safe cleanup (collections) : org.hibernate.engine.loading.internal.CollectionLoadContext@4d7d18da<rs=HikariProxyResultSet@2035306242 wrapping Result set representing update count of -1>....
    .....

员工实体

@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.DETACH, CascadeType.REFRESH}, fetch = FetchType.LAZY)
@Fetch(value= FetchMode.SELECT)
@JoinTable(name = "employees_jobs",
        joinColumns = @JoinColumn(name = "employee_id"),
        inverseJoinColumns = @JoinColumn(name = "job_id"))

工作实体

@ManyToMany(mappedBy = "jobs")
private Set<Employee> employees = new HashSet<>();

提前感谢!

mysql spring hibernate jpa one-to-one
1个回答
0
投票

已解决!是由龙目岛引起的。我删除了@Data注释并添加了

@ToString(exclude = "listName")

在实体类的顶部。 Lombok生成的ToString方法是stackoverflow错误的原因]

© www.soinside.com 2019 - 2024. All rights reserved.