Ok, I am most assuredly doing something stupid .. but I have read all I could and can't find what.
I am using The Hibernate EJB 3 annotations with the Hibernate sesion management.
I have a relation like the following
class Parent
{
Collection<Child> mChildren = new ArrayList<Child>();
@OneToMany(cascade = CascadeType.ALL, mappedBy="parent")
public Collection<Child> getChildren()
{
...
}
}
class Child
{
private Parent mParent;
@ManyToOne
public Parent getParent()
{
...
}
}
Once create, delete works as expected. The children gets removed from the database.
However, if I keep the parent, and replace the children, the old children are left behind in the database! So that next time the Object gets loaded, it has all the old and new children ...
Now, this is pretty basic stuff .. so please can someone point me in the right direction?
Thanks.
Steve
|