| 
					
						 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 
					
  
						
					 |