在@OneToMany与@OneToOne中使用orphanRemoval = true时候
改动保存时候setXXX
org.springframework.orm.hibernate3.HibernateSystemException: A collection with cascade="all-delete-orphan" was no longer referenced by the owning entity instance:
解决方式:
1.将setXXX改为private
2.加入一个add方法
public void addXXX(List<T> ts)
{ this.ts.clear(); if (null != ts&& !ts.isEmpty()) { this.ts.addAll(ts); } }须要setXXX时使用addXXX