error:Found shared references to a collection:
来源:互联网 发布:讯飞语音输入法 mac 编辑:程序博客网 时间:2024/06/06 04:35
错误: Found shared references to a collection:
原因:BeanUtil.copyProperties()的方式复制一个实体bean,如果这个实体bean有一个集合属性,因为这个方法只是做了一个浅拷贝,所以新拷贝的实体跟旧的实体引用了同一个集合,而这个在hibernate中是不允许的,所以报错。
解决:在进行copyProperties拷贝后,新建一个集合,将原来的集合元素添加进去,并赋值给新拷贝的实体。
例:
BeanUtils.copyProperties(oldApplications, newApplications);
Set<ApplicationsUniv> appSet = oldApplications.getApplicationsunivs();
if(null!=appSet || !appSet.isEmpty()){
Set<ApplicationsUniv> newappSet = new HashSet<ApplicationsUniv>() ;
for(ApplicationsUniv appuniv : appSet){
newappSet.add(appuniv);
}
newApplications.setApplicationsunivs(newappSet);
}
- error:Found shared references to a collection:
- Found shared references to a collection
- hibernate异常"Found shared references to a collection"
- hibernate异常"Found shared references to a collection"
- NHibernate异常"Found shared references to a collection"
- hibernate异常"Found shared references to a collection
- hibernate异常"Found shared references to a collection 解决方法
- hibernate异常"Found shared references to a collection
- HibernateException: Found shared references to a collection 解决办法
- Found shared references to a collection: com.morepower.domain.oa.TreeNode.permissions
- 使用hibernate,在面对复杂业务处理的时候,你是否很顺手,由Exception-found shared references to a collection说开去
- HibernateException Found shared references
- Hibernate JPA —— could not insert 或 detach entity passed to persist 或Found shared references 错误
- configure: error: libmpfr not found or uses a different ABI (including static vs shared).
- Service References to a MTOM web services
- 解决 Error:The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this
- ldd not found/error while loading shared libraries
- how to strip a shared library
- models生成与加载
- Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated
- 使用公式C=(5/9)(F-32)打印下列华氏温度与摄氏温度对照表。
- 关于spring注解的配置文件说明context:annotation-config和context:component-scan
- 数据库索引 类型
- error:Found shared references to a collection:
- 作业2:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153 是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。
- 【错误】安装Vim出现错误kde-config-telepathy-accounts > 15.04
- Python判断中文字符串是否相等
- BZOJ 4033: [HAOI2015]树上染色 树形dp
- Java运行时异常和非运行时异常
- 【矩阵快速幂】
- 二叉树的前序、中序和后序遍历
- Java SE Primer——集合框架 完全解析