-->
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.  [ 3 posts ] 
Author Message
 Post subject: ObjectNotFoundException when delete child in many-to-one
PostPosted: Tue Mar 09, 2004 6:18 pm 
Beginner
Beginner

Joined: Wed Oct 08, 2003 4:22 pm
Posts: 29
Hello,

I have a parent-child relationship between ResultSet and KPI. But don't want to cascade a deletion of a ResultSet to the child KPIs, so this property is not set in the mapping.

I get an ObjectNotFoundException when the following occurs:

*delete ResultSet "TestRs" with ID = 101
*had existing KPI which had reference to "TestRs"; i.e. the ResultSetId column in the KPI table still had ID 101, but this ResultSet no longer exists
*when attempt to retrieve list of KPIs, get ObjectNotFoundException thrown

KPI
Code:
public class KPI {

    private ResultSetVO kpiResult = null;
// getters, setters...



So KPI has a reference to its parent ResultSet.


The KPI mapping is as follows:

Code:
   <class name="tap.KPI" table="KPI">
      <id name="id" column="ID" type="long">
         <generator class="net.sf.hibernate.tap.SessionBeanSequenceGenerator"/>
      </id>
      <property name="label" column="Label"/>
      <many-to-one name="kpiResult" class="tap.ResultSetVO" cascade="save-update" column="ResultSetId" />
   </class>


The KPI table has columns ID, Label, and ResultSetId.

When the ResultSet in question is deleted (the one w/ id 101), the ResultSetId column in the KPI table still references 101, as expected. HOWEVER: is there a way to make this a non-exception, somehow indicate that ResultSetId might refer to a deleted ResultSet?

Thanks,
Alex


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 09, 2004 8:08 pm 
Beginner
Beginner

Joined: Wed Oct 08, 2003 4:22 pm
Posts: 29
Sorry, subject should have read "...exception when delete parent" NOT child


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 10, 2004 4:36 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, Hibernate must be based on a proper relational usage. You can however not map the association (only the id) and link it manually.

_________________
Emmanuel


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