【示例】

@OneToMany(fetch=FetchType.LAZY)
@JsonIgnore
@Fetch(FetchMode.SELECT)
@Cascade(value={CascadeType.SAVE_UPDATE})
@JoinColumn(name="userId",updatable=false)
private Set<UserRoleBean> userRoleSet = new HashSet<UserRoleBean>();

----------------------------------------------------------------------------------------------

【说明】

json序列化时将java bean中的一些属性忽略掉,序列化和反序列化都受影响

上述代码userRoleSet 属性上加了  @JsonIgnore,这个时候从后台推数据到前台的时候,就会把userRoleSet 这个引用属性给忽略掉。

避免返回写json时报错:

HTTP Status 500 - Could not write JSON: failed to lazily initialize a collection of role: 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-04
  • 2021-07-05
  • 2021-09-08
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-04
  • 2021-10-19
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案