JPA 级联更新去孤子
class A{ private Set<B> bs = new HashSet<B>();@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "flowNode", orphanRemoval = true)@OrderBy(clause = "id")public Set<B> getBs() {return bs;}}
?
调用操作代码:
A a = new A();Set<B> bs = new HashSet<B>();bs.add(...)a.getBs().clear();a.getBs().addAll(bs);
?
?
?