-->
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: one-to-many array canot remove child link afterchilddeletion
PostPosted: Tue Feb 08, 2005 12:14 am 
Newbie

Joined: Mon Jan 17, 2005 7:32 am
Posts: 13
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
2.1.6
Mapping documents:
/**
* @hibernate.array
* cascade="all"
* @hibernate.collection-key
* column="FK_USER_ACTIVITY_ID"
* @hibernate.collection-one-to-many
* class="Activity"
* @hibernate.collection-index
* column="ACTIVITY_INDEX"
*/
Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
org.apache.commons.beanutils.NestedNullException:

Name and version of the database you are using:
mySQL 4.1



After deleting the child Activity the link from parent to child is still not removed.... For example if the parent has 4 children then I remove one child in the database and set the deleted child to null and save the parent and try to reload the parent I still get 4 children... It is much simpler using List but my goal is to use array object and not List. Please help....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 10, 2005 1:24 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
there is a bug in your code. But you don't show it... Try to simplify your pb in a simple testcase

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 12:29 am 
Newbie

Joined: Mon Jan 17, 2005 7:32 am
Posts: 13
emmanuel wrote:
there is a bug in your code. But you don't show it... Try to simplify your pb in a simple testcase



UserActivity object has one-to-many relationship with Activity object (children)....

This are the steps I did in saving my UserActivity method:
1) removeMarkDeletedActivity(userActivity);
2) dao.saveUserActivity(userActivity); // save my
3) return this.getUserActivity(userActivity.getUserActivityId()); // retrieve the object again here....


inside removeMarkDeletedActivity():
List list = new ArrayList();
ActivityVO[] activity = userActivity.getDailyActivities();
for (int i=0; i < activity.length; i++)
{
if (activity[i] != null && activity[i].isMarkDeleted())
{
list.add(activity[i]);
activity[i] = null;
}
}

// Delete activities
dao.removeUserActivityChild(list); //<-- this will delete activity object

--------- end of my removeMarkDeletedActivity() ------


Should I recreate my array before saving instead of leaving it blank?
Thanks for your reply 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.