-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Don't dereference a collection with cascade="all-delete
PostPosted: Mon Jun 12, 2006 3:17 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
Hi,
I have a very weird problem. I have a method doSomething() in a java application implemented in Spring. When I run the method without putting any decalarative transactions in the application-context.xml it works fine. But the moment I put the transactions like <prop key="doSomething">PROPAGATION_REQUIRED</prop> I start getting the error that says "Don't dereference a collection with cascade="all-delete-orphan": A.myCollection". If I change the cascade attribute to "all" instead of "all-delete-orphan" it starts working and I donot get any error. But I need to know that if the function works fine with "all-delete-orphan" cascade without using transactions, then why does it fail when I add transactions to it.



Hibernate version:3.0


I have a class A wherein I have a collection of instances of class B in the following manner-


Class->
class A{
private List myCollection;

public void writeMyCollection(List myCollection) {
this.myCollection = myCollection;
}


}

Mapping documents->
<class name="A" table="A">
<id name="id" type="long" column="ID" unsaved-value="0">
<generator class="native"/>
</id>
<list lazy="true" name="myCollection" access="field" cascade="all-delete-orphan">
<key column="SOME_ID"/>
<index column="SORT_INDEX"/>
<one-to-many class="B"/>
</list>
</class>




Code between sessionFactory.openSession() and session.close():->
public void doSomething(long id, List collection){
A a = (A) this.getHibernateTemplate().get(A.class,
new Long(Id));
a.writeMyCollection(collection);

}



Full stack trace of any exception that occurs:->
org.springframework.orm.hibernate3.HibernateSystemException: Don't dereference a collection with cascade="all-delete-orphan": A.myCollection; nested exception is org.hibernate.HibernateException: Don't dereference a collection with cascade="all-delete-orphan": A.myCollection
org.hibernate.HibernateException: Don't dereference a collection with cascade="all-delete-orphan": A.myCollection
at org.hibernate.engine.Collections.processDereferencedCollection(Collections.java:70)
at org.hibernate.engine.Collections.processUnreachableCollection(Collections.java:38)
at org.hibernate.event.def.AbstractFlushingEventListener.flushCollections(AbstractFlushingEventListener.java:211)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:71)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:39)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:711)
at org.hibernate.impl.SessionImpl.prepareQueries(SessionImpl.java:895)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:885)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:834)



Please let me know if you need any more details or anything is not clear.

Thanks in Advance,
Ashish Abrol


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 18, 2006 9:17 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 9:07 am
Posts: 27
After downloading Hibernate's new 3.1.3 version I am no longer facing this issue and the problem seems fixed.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.