jpa - Circular reference in JSON call bring id and ref thus undefined values to the option list
问题描述
I have an optionlist that is bringing undefined values in dropdown along with few values. In response data only few values are coming with ID rest are REF(undefined). The entity it's linked to has a column ID and another column which is self join to ID named parent_set. Below code shows entity:-
@JsonDeserialize
@JsonIdentityInfo(generator = JSOGGenerator.class)
@EqualsAndHashCode(of = {"id"})
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, ignoreUnknown = true)
@Entity
public class QSet implements Identifiable {
@Getter
@Setter
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(name = "id", length = 32)
private String id;
@Getter
@Setter
@Column(name = "name")
private String name;
@Getter
@Setter
@ManyToOne(optional = false, fetch = FetchType.EAGER)
@JoinColumn(name = "parent_set")
private QuestionSet parentSet;
}
HTML:-
<select ng-model="newstage.questionSet" id="questionSet" name="questionSet"
data-toggle="tooltip" class="form-control" ng-options="set.id as set.displayText for set in qSets"/>
JS:-
$scope.qSets = response.data;
On debugging response data is :-
0: {@id: "1", id: "8a", name: "Test", parentSet: {…}, …}
1: {@ref: "113"}
2: {@id: "343", id: "8a81813a69fd55a5016a25c5ab9e0468", name: "test3", parentSet: null, …}
In this case the value is coming as undefined for the second item in the list because it is referenced in parentset of id 1. How can I resolve this issue?
解决方案
那么修复是解码响应数据如下:
$scope.qSet = JSOG.decode(response.data);
推荐阅读
- c - 为什么当我重复调用它 l 30 次时 realloc() 返回 NULL?
- r - 无法使用 ggtree 绘制 hclust 对象
- java - 使用 FXML 在 JavaFX 中绘制线条
- python - 将几何列转换为地理数据框中的纬度/经度列
- vue.js - Vuetify,将值设置为 v-select 忽略项目
- android - 我该如何解决“比较方法违反其总合同!” Kotlin 的问题?
- c++ - C++ 中设置数据文件的简单/稳健方法
- python - 如何获取 datetime.date 对象的工作日
- python - 使用 pandas 识别最近的物体
- sql - 我希望根据 SQL 中的字段/列返回限制数