Jpa JSON调用中的循环引用将id和ref(因此未定义的值)带到选项列表中

Jpa JSON调用中的循环引用将id和ref(因此未定义的值)带到选项列表中,jpa,jackson,self-join,circular-reference,idref,Jpa,Jackson,Self Join,Circular Reference,Idref,我有一个选项列表,它在下拉列表中提供了一些未定义的值和一些值。在响应数据中,ID rest为REF(未定义)的值很少。它链接到的实体有一个列ID和另一个列,该列自连接到名为parent_set的ID。以下代码显示实体:- @JsonDeserialize @JsonIdentityInfo(generator = JSOGGenerator.class) @EqualsAndHashCode(of = {"id"}) @JsonIgnoreProperties(value =

我有一个选项列表,它在下拉列表中提供了一些未定义的值和一些值。在响应数据中,ID rest为REF(未定义)的值很少。它链接到的实体有一个列ID和另一个列,该列自连接到名为parent_set的ID。以下代码显示实体:-

@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"/>
调试时,响应数据为:-

0: {@id: "1", id: "8a", name: "Test", parentSet: {…},  …}
1: {@ref: "113"}
2: {@id: "343", id: "8a81813a69fd55a5016a25c5ab9e0468", name: "test3", parentSet: null,  …}

在这种情况下,列表中的第二项的值是未定义的,因为它在id为1的父集合中引用。如何解决此问题?

解决方法是对响应数据进行解码,如下所示:

 $scope.qSet = JSOG.decode(response.data);

修复方法是解码响应数据,如下所示:

 $scope.qSet = JSOG.decode(response.data);