我有两个模型类.一个是
@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’:找不到后引用属性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)