我有一个类别表,它有一个父子关系,当我插入MySQL关系不工作的数据时,我看到空子关系,但当我从邮递员那里发送同样的请求时,它工作了。我在试着理解背后是什么?有人能给我解释一下吗?
@JsonManagedReference(value = "parent_category")
@OneToMany(fetch = FetchType.LAZY, mappedBy = "parent")
private Set<CatalogCategory> children = new HashSet<>();
@ManyToOne
@JoinColumn(name = "parentId")
@JsonBackReference(value = "parent_category")
private CatalogCategory parent;发布于 2021-04-21 18:32:39
对于邮递员,您将使用这些JPA注释,因为您将运行Java应用程序的代码。
JPA将生成一些SQL请求来插入此数据。您可以使用以下配置在日志中显示此请求:https://www.baeldung.com/sql-logging-spring-boot
我认为您在MySQL数据库中插入的SQL请求是不同的。
https://stackoverflow.com/questions/67193984
复制相似问题