如何使用javafx listproperty在jpa实体类中编写OneToMany关系 我试过这个:
private final ListProperty<Bill> bills = new SimpleListProperty<>();
@OneToMany(targetEntity = Bill.class, mappedBy = "invoice")
public ObservableList getBills() {
return bills.get();
}
public void setBills(ObservableList value) {
bills.set(value);
}
public ListProperty billsProperty() {
return bills;
}
得到错误:&#34; oneTomany属性类型应为[java.util.colletion,java.util.List]
答案 0 :(得分:0)
仅使用List而不是getter和setter函数中的ObservableList。
private final ListProperty<Bill> bills = new SimpleListProperty<>();
@OneToMany(targetEntity = Bill.class, mappedBy = "invoice")
public List getBills() {
return bills.get();
}
public void setBills(List value) {
bills.set(FXCollections.observableArrayList(value));
}
public ListProperty billsProperty() {
return bills;
}