gpt4 book ai didi

java - 在实体 hibernate 中循环

转载 作者:行者123 更新时间:2023-12-02 10:28:55 24 4
gpt4 key购买 nike

我有两个实体,当我想要获取grade.getSubcompetence()时。当我保存实体时发生错误,因为子能力数据为空。当我调试时,我看到错误:

'java.lang.StackOverflowError' exception. Cannot evaluate _$$_jvstea5_f.toString()

等级实体:

@Entity
@Data
@NoArgsConstructor
@ToString(exclude = {"subcompetence"})
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(name = "GRADE")
public class Grade {
@JsonBackReference
@ManyToOne(
fetch = FetchType.LAZY,
optional = false)
@JoinColumn(name = "SUBCOMPETENCE_ID", nullable = false)
private Subcompetence subcompetence;

@JsonBackReference
@ManyToOne(
fetch = FetchType.LAZY,
optional = false)
@JoinColumn(name = "LEVEL_ID", nullable = false)
private Level level;
}

子能力实体:

@Entity
@Data
@NoArgsConstructor
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Table(name = "SUBCOMPETENCE")
public class Subcompetence {

@JsonManagedReference
@OneToMany(
mappedBy = "subcompetence",
fetch = FetchType.LAZY,
cascade = CascadeType.ALL)
private List<Grade> grades;
}

最佳答案

尝试在您的子能力类别中添加@EqualsAndHashCode(exclude="grades")

关于java - 在实体 hibernate 中循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53722470/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com