首页 > 数据库技术 > 详细

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

时间:2016-03-31 18:31:57      阅读:229      评论:0      收藏:0      [点我收藏+]
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解决方法

原文:http://www.cnblogs.com/hzhh123/p/5342108.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!