所以,我正试图从服务器获取我的学生对象到我的androidClient,但我有ifinity循环。如果我使用@JsonBackReference / @JsonManagedReference或@JsonIgnore,我将无法获得像无限循环的对象,所以我有一个问题如何做到这一点?在这里我的课程:
Student.java
@Entity
@Table(name ="student")
public class Student {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GenericGenerator(name="increment", strategy = "increment")
private int id_student;
@Column(name = "studentName", nullable = false)
private String studentName;
@Column(name = "formOfAducation")
private String formOfAducation;
@ManyToOne
@JoinColumn(name ="id_group")
@JsonBackReference
private Group group;
@Column(name = "studentCourse")
private String studentCourse;
@Column(name = "studentSpecializatio")
private String studentSpecializatio;
@Column(name = "studentBookName")
private String studentBookName;
@Column(name = "studentGender")
private String studentGender;
public Student(){
}
//getter-setters
}
Group.java
@Entity
@Table(name = "party")
public class Group {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@GenericGenerator(name="increment", strategy = "increment")
private int id_group;
@Column(name = "groupName", nullable = false)
private String groupName;
@OneToMany(targetEntity = Student.class, mappedBy = "group", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JsonManagedReference
private List<Student> student;
public Group(){
}
在客户端上我有相同的类,当我试图只从组中传递id时,我无法在客户端反序列化它。希望你能帮助我。或者没有办法做到这一点,那么如何从客户端编辑Student对象?
答案 0 :(得分:2)