Hibernate :Found shared references to a collection
程序员文章站
2022-04-16 08:53:07
...
项目中在session.flush(); 抛了异常
遇到这个问题原因是:1.表之间有关联。在复制数据。
用了hibernate,并在复制数据时将要复制的数据对象A的所有属性赋给了对象B。
解决方案:
将那些关联的数据也复制一遍,并更新B的那些关联对象。这些关联数据中的一个或多个为空时也必须更新B中相应的关联对象
IForwardDateStockOrder fwdStockOrder
if(!stockOrder.getIsChgWaive()){//if is_chag_waive =0 exists stock charges.
List<IStockCharge> stockCharges = new ArrayList<IStockCharge>();
logger.info("fwdStockOrder.getFwStockCharges" +fwdStockOrder.getFwStockCharges());
BeanUtils.copyProperties(fwdStockOrder.getFwStockCharges(),stockCharges);
logger.info("stockOrder stockCharges" + stockCharges);
stockOrder.setStockCharges(stockCharges);
}else{
stockOrder.setStockCharges(null);
}
然后再set进去就不会出现该问题
上一篇: Tomcat内存溢出解决方案
下一篇: Tomcat内存溢出解决方案
推荐阅读
-
Hibernate :Found shared references to a collection
-
Hibernate JPA —— could not insert 或 detach entity passed to persist 或Found shared references 错误
-
hibernate异常Found shared references to a collection
-
org.hibernate.HibernateException: Found shared references to a collection: com.jinyi.ihome.module.ex...
-
HibernateSystemException: Found shared references to a collection:
-
HibernateException: Found shared references to a collection 解决办法
-
Hibernate :Found shared references to a collection
-
Hibernate异常Found shared references的解决办法