hibernate错误:org.hibernate.NonUniqueObjectException: a different object with the same identifier valu
2014-05-20 15:57
781 查看
if (StringUtil.isNotEmpty(supplyCatalog.getId())) { message = "更新成功"; SupplyCatalogEntity t = supplyCatalogService.get(SupplyCatalogEntity.class, supplyCatalog.getId()); // 1 //org.hibernate.Session session = systemService.getSession(); //session.clear(); try { if (StringUtil.isNotEmpty(request.getParameter("warehouseId0"))) { t.setWarehouseId(Integer.valueOf(request.getParameter("warehouseId0"))); } t.setLatestTime(new Date()); t.setLatestUser(this.getSysUserName(request)); MyBeanUtils.copyBeanNotNull2Bean(supplyCatalog, t); if (t.getParentCatalog() != null && t.getParentCatalog().getId() == null) { t.setParentCatalog(null); } // 2 //SupplyCatalogEntity parent = systemService.get(SupplyCatalogEntity.class, t.getParentCatalog().getId()); //t.setParentCatalog(parent); supplyCatalogService.saveOrUpdate(t); systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO); } catch (Exception e) { e.printStackTrace(); } }
一开始报错:org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session
然后添加了“1”处被注释的代码,这样把session中冲突的实体清除了,不报错了。
但是看数据库,发现父节点的数据记录被清空了,只留了一个id。
之后添加了“2”处的代码,就能存住父节点信息了。
相关文章推荐
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: A different object with the same identifier解决方法
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was alread---------程序报错
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was ...
- org.hibernate.NonUniqueObjectException: A different object with the same identifier value was alread
- org.hibernate.NonUniqueObjectException:a different object with the same identifier value was alread
- 报错信息:Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier
- org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the sessio
- org.hibernate.NonUniqueObjectException: a different object with the same ide
- org.hibernate.NonUniqueObjectException: a different object with the same ide
- .NonUniqueObjectException: a different object with the same identifier等的解决