First thank You for Your answer. I know that I should do something like that, but I supposed that the hibernate does all these things for me. As You can see in my code, I use "all-delete-orphan" at the movie side and will that the hibernate delete all copies too (children from the movie!).
In my case does the hibernate that for me, but I have a problem with association with rental class. Each time when I want to delete the copy from the list in movie, hibernate try to make this node transient too. But there I reach this exception when I want to delete all Rentals because these show onto copy. I am in circle, i suppose.
I don't know ... At least I will do this handy in code, but that is not the real stuff with hibernate.
Thx,
music
batmat wrote:
First, it would be great if you used the code tags to make you more readable. In fact, putting everything in bold is quite uneasy to read...
For your error, I didn't check everything your provided, but I guess you didn't update both directions of the relationship: when deleting a child in the parent list, you must code to assure that:
* the parent has no more reference to the child (in the collection, that's to say)
* the child has a null reference to its parent.
Did you do both?
To do this, it's recommended to have a method in the parent that is responsible for maintaining this integrity, something like:
Code:
public void removeChild(Child c)
{
children.remove(c);
c.setParent(null);
}