Request processing failed; nested exception is org. springframework. dao. InvalidDataAccessApiUsageException: Multiple representations of the same entity solution, representations
1. error message
Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessApiUsageException: Multiple representations of the same entity
2. Error cause
This is because an attempt is made to assign a Persistent object or Detached object value to a certain attribute of a new Transient object. This error is reported when the last save or merge Transient object is saved.
3. Solutions
This is a bug of Hibernate, which has been fixed in version 4.2.15.
1. Update the hibernate version to 4.2.15 or later.
2. Add the following attributes to the hibernate configuration file:
<property name="hibernate.event.merge.entity_copy_observer">allow</property>
|
If you use Spring to manage hibernate, configure
<prop key="hibernate.event.merge.entity_copy_observer">allow</prop>
|
Reference: 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/