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
|
|