-->
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.  [ 4 posts ] 
Author Message
 Post subject: all-delete-orphan (null pointer exception)
PostPosted: Wed Oct 22, 2003 11:43 am 
Newbie

Joined: Thu Oct 09, 2003 6:57 am
Posts: 17
Location: France
Hi all,

I have 3 classes :

ConflictInfo
Conflict which has a List of ConflictInfo
Ncuser which has a List of ConflictInfo

The Mapping files are :

ConflictInfo


Code:
<class name="com.newcompany.business.ConflictInfo" table="ncuserconflict">
   <id name="id" type="int" column="id">
      <generator class="sequence">
      <param name="sequence">seq_ncuserconflict</param>
      </generator>
   </id>

   <many-to-one name="conflict" class="com.newcompany.business.Conflict" column="ref_conflict" not-null="true"/>

   <many-to-one name="ncuser" class="com.newcompany.business.Ncuser" column="ref_ncuser" not-null="true"/>

   <many-to-one name="part" class="com.newcompany.business.Part" column="ref_part"/>

   <many-to-one name="conflictarg" class="com.newcompany.business.Conflictarg" column="ref_conflictarg"/>

</class>
</hibernate-mapping>

Ncuser

Code:
...
<list name="conflictInfos" lazy="true" table="ncuserconflict" inverse="true"  cascade="all">
   <key column="ref_ncuser" foreign-key="ref_ncuser"  />
   <index column="ref_conflict"/>
   <one-to-many class="com.newcompany.business.ConflictInfo"/>
</list>
...


Conflict

Code:
<list name="conflictInfos" lazy="true" table="ncuserconflict" inverse="true" cascade="all">
   <key column="ref_conflict" foreign-key="ref_conflict"/>
   <index column="ref_ncuser"/>
   <one-to-many class="com.newcompany.business.ConflictInfo"/>
</list>



Ok, now, when I want to delete a Ncuser or a Conflict, this works very good and delete also the persisted ConflictInfo.


But if I replace cascade="all" with cascade="all-delete-orphan" I have an error :

java.lang.NullPointerException
at net.sf.hibernate.impl.SessionImpl.getPersister(SessionImpl.java:2562)
at net.sf.hibernate.impl.SessionImpl.isSaved(SessionImpl.java:2599)
at net.sf.hibernate.collection.PersistentCollection.identityRemove(PersistentCollection.java:607)
at net.sf.hibernate.collection.PersistentCollection.identityRemoveAll(PersistentCollection.java:601)
at net.sf.hibernate.collection.List.getOrphans(List.java:43)
at net.sf.hibernate.impl.SessionImpl.getOrphans(SessionImpl.java:3195)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:411)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:312)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1101)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1044)
at net.sf.hibernate.engine.Cascades$1.cascade(Cascades.java:58)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:296)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1121)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1044)
at net.sf.hibernate.engine.Cascades$1.cascade(Cascades.java:58)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:296)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:404)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:312)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1101)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1044)
at com.newcompany.dao.UserHibernateDAO.deleteUser(UserHibernateDAO.java:220)
at Test.test(Test.java:107)
at Test.main(Test.java:117)
Exception in thread "main" Process terminated with exit code 1


I think, it's like that hibernate don't detect the same ConflictInfo refers COnflict and Ncuser. It's a "buckle" ?.

Did I make an error on my mapping ? This is possible to do that ? Or I should keep "cascade="all" and my application will explicitly delete the ConflictInfo when I remove a ConflictInfo from a List ?

Thank you

J


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 22, 2003 1:14 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Actually, it looks like we were just missing a null check in the orphan-delete code. I have made a fix in CVS.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 5:36 am 
Newbie

Joined: Thu Oct 09, 2003 6:57 am
Posts: 17
Location: France
I have download the last CVS snapshot.

But now I get this error :

java.lang.NullPointerException: attempted to delete null
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:993)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:412)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:312)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1103)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1046)
at net.sf.hibernate.engine.Cascades$1.cascade(Cascades.java:58)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:296)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1123)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1046)
at net.sf.hibernate.engine.Cascades$1.cascade(Cascades.java:58)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:296)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:404)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:312)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:361)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:341)
at net.sf.hibernate.impl.SessionImpl.doDelete(SessionImpl.java:1103)
at net.sf.hibernate.impl.SessionImpl.delete(SessionImpl.java:1046)
at com.newcompany.dao.UserHibernateDAO.deleteUser(UserHibernateDAO.java:220)
at Test.test(Test.java:108)
at Test.main(Test.java:117)
Exception in thread "main" Process terminated with exit code 1


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 23, 2003 6:10 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
OK. one more null check. I'll have to add a test case for this....

(ie. for the case of a List with null elements.)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.