-->
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.  [ 1 post ] 
Author Message
 Post subject: override DELETE_ORPHAN behavior
PostPosted: Sat Mar 21, 2009 8:35 pm 
Newbie

Joined: Mon Sep 08, 2008 5:09 am
Posts: 6
Location: Cluj-Napoca
Hi,

I have a interesting problem with the cascading annotation.
I have a class Customer which has a list of invoices. the list of invoices is annotated like this:

@ManyToMany(cascade=CascadeType.ALL)
@Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})
public List<Invoice> getInvoices()
{
return this.invoices;
}

What I want to do is when I have a customer1 object that has an reference to invoice1 into the invoices list for example I want to change this and the customer2 to have the reference to the invoice1. If I'm removing and adding to the invoices lists in the 2 customer objects I'm getting some exceptions. the problem is that when I delete from the customer1 invoices list the invoice id deleted also.

in my service layer I do somehting like this:

customer1.getInvoices().remove(invoice)
save(customer1)


Do you have an idea how to make this thing work, to change the association without deleting the child.

thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.