We are working on Hibernate upgrade in my project. We were on hibernate 3.3.1, spring version 3.1.1 and working with JPA 2.0 as persistence layer. Now I am trying to upgrade Hibernate 4.3.1. we have done all necessary dependencies for this upgrade.
Able to build our project fine but when I run our JUnit tests, am getting Found shared references to a collection error (I have upgraded to Hibernate 4.3.1 with JPA 2.1 and Spring 3.1.1 in our project now). Can you please help me to solve this error .
Caused by: org.hibernate.HibernateException: Found shared references to a collection: com.carlson.cwt.portrait.domain.traveler.BusinessT raveler.addresses at org.hibernate.engine.internal.Collections.processR eachableCollection(Collections.java:180) at org.hibernate.event.internal.FlushVisitor.processC ollection(FlushVisitor.java:59) at org.hibernate.event.internal.AbstractVisitor.proce ssValue(AbstractVisitor.java:121) at org.hibernate.event.internal.AbstractVisitor.proce ssValue(AbstractVisitor.java:82) at org.hibernate.event.internal.AbstractVisitor.proce ssEntityPropertyValues(AbstractVisitor.java:76) at org.hibernate.event.internal.DefaultFlushEntityEve ntListener.onFlushEntity(DefaultFlushEntityEventLi stener.java:172) at com.carlson.cwt.portrait.domain.event.ProfileEntit yFlushEventListener.onFlushEntity(ProfileEntityFlu shEventListener.java:37) at org.hibernate.event.internal.AbstractFlushingEvent Listener.flushEntities(AbstractFlushingEventListen er.java:231) at org.hibernate.event.internal.AbstractFlushingEvent Listener.flushEverythingToExecutions(AbstractFlush ingEventListener.java:102) at org.hibernate.event.internal.DefaultAutoFlushEvent Listener.onAutoFlush(DefaultAutoFlushEventListener .java:61) at org.hibernate.internal.SessionImpl.autoFlushIfRequ ired(SessionImpl.java:1187) at org.hibernate.internal.SessionImpl.list(SessionImp l.java:1253) at org.hibernate.internal.QueryImpl.list(QueryImpl.ja va:103) at org.hibernate.jpa.internal.QueryImpl.list(QueryImp l.java:573) at org.hibernate.jpa.internal.QueryImpl.getResultList (QueryImpl.java:449) at org.springframework.orm.jpa.JpaTemplate$12.doInJpa (JpaTemplate.java:370) at org.springframework.orm.jpa.JpaTemplate$12.doInJpa (JpaTemplate.java:1) at org.springframework.orm.jpa.JpaTemplate.execute(Jp aTemplate.java:187) ... 42 more
My mappings are as below between BusinessTraveler and TravelerAddress:
in BusinessTraveler class: @OneToMany (cascade = CascadeType.ALL, orphanRemoval = true, mappedBy = "businessTraveler") private Set<TravelerAddress> addresses = new HashSet<TravelerAddress>();
in TravelerAddress class: @ManyToOne @JoinColumns ({ @JoinColumn (name = "BUSINESS_TRAVELER_ID", nullable = false, insertable = false, updatable = false), @JoinColumn (name = "BUSINESS_TRAVELER_ORIG_ID", nullable = false, insertable = false, updatable = false) }) private BusinessTraveler businessTraveler;
Is this Found shared references to a collection occurs due to mappings? or because of some else in project??
|