Working with Hibernate-EntityManager 4.3.5 I'm getting the HibernateException: Found two representations of the same collection.
The scenario is that I have 2 entities A and B; both with relationship to a third entity C. A also have a relationship with B. Let's try to make it clear:
A -> OneToOne with B and C
B -> OneToMany with C
A and B are loaded in different transactions (Interceptors) but next I make A.setXXX(B) and do a entityManager.merge(A); -- A have an instance of C and B another, but they represent the same instance (same ID or primary key). Because of that, I'm getting this error - in fact, I have 2 different instances of C (one with A and another with B) that represent the same entity (same PK). How to solve this? I thought of doing something like B.setXXX(a.getXXX()) but it sounds very messy. Any suggestions?