2 回答
TA贡献1906条经验 获得超10个赞
此问题与 JPA 双向映射无关。它在反序列化时引发错误。
Partida -> 应具有零参数构造函数
请求有效负载应具有 { “partida”:{“id”:123}},以便填充 partida 对象属性。
TA贡献1834条经验 获得超8个赞
有关详细信息,请查看此链接杰克逊图书馆。
@Entity
public class Partida implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String timeA;
private String timeB;
private boolean visitante;
public Partida(){
//Default constructor required here
}
@OneToMany(mappedBy = "partida", fetch = FetchType.LAZY, cascade =
CascadeType.ALL)
private List<Set> sets;
public List<Set> getSets() {
return sets;
}
public void setSets(List<Set> sets) {
this.sets = sets;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getTimeA() {
return timeA;
}
// Mocado o valor pois o Time A sempre e a Sao Judas
public void setTimeA(String timeA) {
this.timeA = timeA;
}
public String getTimeB() {
return timeB;
}
public void setTimeB(String timeB) {
this.timeB = timeB;
}
public boolean isVisitante() {
return visitante;
}
public void setVisitante(boolean visitante) {
this.visitante = visitante;
}
}
如果问题未解决,请尝试 JSON 创建者
@JsonCreator
public Partida(@JsonProperty("id") Long id, @JsonProperty("timeA") String
timeA, @JsonProperty("timeB") String timeB, @JsonProperty("desc") boolean
visitante) {
this.id = id;
this.timeA = timeA;
this.timeB= timeB;
this.visitante= visitante;
}
添加回答
举报