-->
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: Why can not I delete the object get by the relation
PostPosted: Tue Oct 04, 2005 11:42 pm 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
When I delete some objects whicc get from the relation, it throws the following exception.

could not delete collection: [mo.umac.eticketing.common.valueobject.discount.DiscountCriteriaVO.discountCriteriaValueVOs#1180]

public void preDelete() throws AppException {
int size = getDiscountCriteriaVOs().size();
for(int i=0;i<size;i++) {
DiscountCriteriaVO discountCriteriaVO = (DiscountCriteriaVO)getDiscountCriteriaVOs().remove(0);
discountCriteriaVO.delete();
}
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 12:35 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
/**
* @hibernate.bag lazy="true"
* @hibernate.collection-key column="criteriaId"
* @hibernate.collection-one-to-many class="DiscountCriteriaValueVO"
*/
public List getDiscountCriteriaValueVOs() {
return discountCriteriaValueVOs;
}

public void preDelete() throws AppException {
for(int i=getDiscountCriteriaValueVOs().size()-1;i>=0;i--) {
DiscountCriteriaValueVO discountCriteriaValueVO = (DiscountCriteriaValueVO)getDiscountCriteriaValueVOs().remove(i);
discountCriteriaValueVO.delete();
}
}

I don't know why it can be delete.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 11:59 pm 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
If delete the discountVO, the child of discount will not be deleted. The hibernate only set the value of the foreign key to be null. In fact, it should delete the object in the database.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 12:01 am 
Newbie

Joined: Mon Aug 29, 2005 12:53 am
Posts: 13
joechang316 wrote:
If delete the discountVO, the child of discount will not be deleted. The hibernate only set the value of the foreign key to be null. In fact, it should delete the object in the database.


/**
* @hibernate.bag lazy="true" cascade="delete-orphan"
* @hibernate.collection-key column="discountId"
* @hibernate.collection-one-to-many class="DiscountCriteriaVO"
*/
public List getDiscountCriteriaVOs() {
return discountCriteriaVOs;
}


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.