java– 无法处理托管后向引用’defaultReference’:找不到后引用属性

java– 无法处理托管后向引用’defaultReference’:找不到后引用属性,第1张

概述我有两个模型类.一个是@Entity(name = 'userTools') @Table(uniqueConstraints = @UniqueConstraint(columnNames = { 'assignToUser_id','toolsType_id' })) @Inheritance(strategy = InheritanceType.JOI

我有两个模型类.一个是

@Entity(name = "userTools")@table(uniqueConstraints = @UniqueConstraint(columnnames = { "assignToUser_ID","toolsType_ID" }))@inheritance(strategy = inheritanceType.JOINED)@JsonTypeInfo(use = JsonTypeInfo.ID.CLASS,include = JsonTypeInfo.As.PROPERTY,property = "classname")@JsonIgnorePropertIEs(ignoreUnkNown = true)public class UserTools {    @ID    @GeneratedValue(strategy = GenerationType.auto)    private Long ID;    @OnetoOne    private ToolsType toolsType;    @OnetoMany(mappedBy = "userTools",fetch = FetchType.EAGER,cascade = { CascadeType.ALL },orphanRemoval = true)    @Cascade(org.hibernate.annotations.CascadeType.DELETE)    @JsonManagedReference    private List

第二是

@Entity(name = "userToolsHistory")@JsonIgnorePropertIEs(ignoreUnkNown = true)public class UserToolsHistory {    @ID    @GeneratedValue(strategy = GenerationType.auto)    private Long ID;    @OnetoOne    private ToolsType toolsType;    @ManyToOne    @JsonIgnore    @JsonBackReference    private UserTools userTools;     private String comments;}

但是在保存时我收到了这个错误:

Can not handle managed/back reference 'defaultReference': no backreference property found from type [collection type; classjava.util.List,contains [simple type,classcom.DW.model.tools.UserToolsHistory]]
最佳答案您面临的例外源于MapPingJackson2httpMessageConverter.

要修复它,请交换注释,以便获得:

public class UserTools {...@JsonBackReferenceprivate List

本教程解释了必须如何完成:jackson-bidirectional-relationships-and-infinite-recursion 总结

以上是内存溢出为你收集整理的java – 无法处理托管/后向引用’defaultReference’:找不到后引用属性全部内容,希望文章能够帮你解决java – 无法处理托管/后向引用’defaultReference’:找不到后引用属性所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1240011.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)