【发布时间】:2017-06-17 18:04:32
【问题描述】:
我在尝试将 bigdecimal 转换为 ObjectProperty 时遇到问题
public class LinePiece {
private int idLine;
private ObjectProperty<BigDecimal> qty = new SimpleObjectProperty<BigDecimal>(BigDecimal.ZERO);
private ObjectProperty<BigDecimal> price = new SimpleObjectProperty<BigDecimal>(BigDecimal.ZERO);
private ObjectProperty<BigDecimal> remise = new SimpleObjectProperty<BigDecimal>(BigDecimal.ZERO);
private IntegerProperty tva = new SimpleIntegerProperty();
private ObjectProperty<BigDecimal> subTotal = new SimpleObjectProperty<BigDecimal>(BigDecimal.ZERO);
// Getters and Setters
}
我们有一组 LinePiece 类型的项目
private Set<LinePiece> LinePieces = new HashSet<>();
LinePieces .add(new LinePiece());
LinePieces .add(new LinePiece());
LinePieces .add(new LinePiece());
对实际集合进行求和后:
BigDecimal sum = lineCommande.stream().map(LineCommande::getSubTotal)
.reduce(BigDecimal.ZERO,BigDecimal::add);
我想让 sum 可观察,所以我可以监听 sum 的变化。 我怎样才能做到这一点?
备注:这里不能使用 ObservableList 因为我使用的是休眠
@OneToMany(mappedBy = "piece", fetch = FetchType.EAGER, orphanRemoval = true, cascade = CascadeType.ALL)
private Set<LinePiece> LinePieces = new HashSet<>();
如果有其他使用 ObservableList 的解决方案,请告诉我。
【问题讨论】:
-
我对Hibernate不熟悉,但假设你必须使用
Set对象,你不能使用ObservableSet吗?
标签: java javafx data-binding