我有一个Order
...
private Collection<OrderCustomField> orderCustomFields;
@OneToMany(mappedBy = "order", cascade = CascadeType.ALL)
public Collection<OrderCustomField> getOrderCustomFields() {
return orderCustomFields;
}
@JsonProperty("CustomFields")
public void setOrderCustomFields(Collection<OrderCustomField> orderCustomFields) {
this.orderCustomFields = orderCustomFields;
}
并且OrderCustomFields
有
private Order order;
@ManyToOne
@javax.persistence.JoinColumn(name = "order_id", referencedColumnName = "id", nullable = false)
public Order getOrder() {
return order;
}
public void setOrder(Order order) {
this.order = order;
}
保存订单时未order_id
填写。OrderCustomField
我认为这cascade = CascadeType.ALL
将处理填充这些值。有没有我错过的东西,或者没有像我想象的那样工作?