Hi,
I am getting this error now when I try to execute a
query.
I have walked into the SessionImpl in my debugger
and it appears that the collection in question is collection of dependent
objects that are of the same type of the host object. IE: Russian Dolls contain
many Russian Dolls.
I would swear that this has been working for a long
time, I dont know what I did to introduce this problem. Since getting this
problem I have upgraded to 2.1.1 and am using the default cache still... I think
its called EHCache.
I also attached my hbm mapping file... The
collection that the debugger pointed me to was called dependents... In my
situation Cases have many dependents which are also Cases....
I guess I am trying to find out who else is sharing
this reference? Any thoughts?
Here is the stacktrace. The mapping is attached at
the end:
net.sf.hibernate.HibernateException: Found shared
references to a collection
at net.sf.hibernate.impl.SessionImpl.updateReachableCollection(SessionIm pl.java:2759) at net.sf.hibernate.impl.FlushVisitor.processCollection(FlushVisitor.jav a:32) at net.sf.hibernate.impl.AbstractVisitor.processValue(AbstractVisitor.ja va:69) at net.sf.hibernate.impl.AbstractVisitor.processValues(AbstractVisitor.j ava:36) at net.sf.hibernate.impl.SessionImpl.flushEntity(SessionImpl.java:2474) at net.sf.hibernate.impl.SessionImpl.flushEntities(SessionImpl.java:2340 ) at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:22 07) at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.jav a:1732) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1499) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1464) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1454) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1446) at com.esage.agility.DAO.BaseDAO.executeQuery(BaseDAO.java:81) The simplified mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd"> <hibernate-mapping>
<class name="com.esage.agility.domain.Case" table="BASE_CASE" discriminator-value="B"> <jcs-cache usage="read-write"/> <id column="BASE_CASE_ID" type="long" name="id" unsaved-value="null"> <generator class="identity"/> </id> <discriminator column="class" type="string"/> <set name="dependents" lazy="true" cascade="all"> <key column="PARENT_CASE_ID"/> <one-to-many class="com.esage.agility.domain.Case"/> </set> <set name="history" lazy="true" cascade="all"> <key column="CASE_ID"/> <one-to-many class="com.esage.agility.domain.CaseHistory"/> </set> <many-to-one name="parent"
class="com.esage.agility.domain.Case"
column="PARENT_CASE_ID"/> <subclass name="com.esage.agility.domain.UserStory" discriminator-value="U"> <property name="title" column="TITLE" type="string"/> </subclass> </class> </hibernate-mapping> |