星空网 > 软件开发 > Java

Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Multiple representations of the same entity解决方法

1、错误信息
Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Multiple representations of the same entity

2、错误原因

因为试图给 某一个new 的Transient对象 的某一个属性赋一个 已经Persistent 对象或者Detached 对象值。导致最后save 或者merge 这个Transient对象报这个错误。

3、解决方案

这应该算是Hibernate 自身的一个bug ,已经在4.2.15版本中解决了

1、更新hibernate版本到4.2.15 以上

2、在hibernate的配置文件中添加如下属性:

<property name="hibernate.event.merge.entity_copy_observer">allow</property>

 

如果使用的Spring 管理hibernate, 在你的spring的数据源中配置

<prop key="hibernate.event.merge.entity_copy_observer">allow</prop>
   
具体参考:http://thinerzq.me/2016/02/01/Multiple-representations-of-the-same-entity-are-being-merged%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/

 

 

 

 

 

 

 

 

  




原标题:Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Multiple representations of the same entity解决方法

关键词:Spring

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

战争险:https://www.goluckyvip.com/tag/48664.html
站点关闭:https://www.goluckyvip.com/tag/48665.html
站斧浏览器:https://www.goluckyvip.com/tag/48666.html
站南服装城:https://www.goluckyvip.com/tag/48667.html
站内闭环:https://www.goluckyvip.com/tag/48668.html
站内关联流量:https://www.goluckyvip.com/tag/48669.html
深圳有没有比较好玩的景点 深圳有没有比较好玩的景点推荐一下:https://www.vstour.cn/a/366175.html
长治婚庆女司仪和主持人:https://www.vstour.cn/a/366176.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流