有一個奇怪的問題,無法弄清楚如何處理。有簡單的POJO:@Entity@Table(name = "persons")public class Person { @Id @GeneratedValue private Long id; @Column(name = "first_name") private String firstName; @Column(name = "middle_name") private String middleName; @Column(name = "last_name") private String lastName; @Column(name = "comment") private String comment; @Column(name = "created") private Date created; @Column(name = "updated") private Date updated; @PrePersist protected void onCreate() { created = new Date(); } @PreUpdate protected void onUpdate() { updated = new Date(); } @Valid @OrderBy("id") @OneToMany(mappedBy = "person", fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true) private List<PhoneNumber> phoneNumbers = new ArrayList<>(); public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getMiddleName() { return middleName; } public void setMiddleName(String middleName) { this.middleName = middleName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getComment() { return comment; }其余端點:@ResponseBody@RequestMapping(method = RequestMethod.GET)public List<Person> listPersons() { return personService.findAll();}在json響應中,除了Id之外,還有其他所有字段,我需要在前端編輯/刪除人員。如何配置Spring Boot來序列化ID?這就是現在的響應:[{ "firstName": "Just", "middleName": "Test", "lastName": "Name", "comment": "Just a comment", "created": 1405774380410, "updated": null, "phoneNumbers": [{ "phoneNumber": "74575754757" }, { "phoneNumber": "575757547" }, { "phoneNumber": "57547547547" }]}]UPD具有雙向休眠映射,可能與問題有關。
添加回答
舉報
0/150
提交
取消