Deleting Child Entities in JDO
I would like to know if the following is possible in JDO.
I have a 1-N relationship between a Parent and a Child class. So my classes look like
@PersistenceCapable
public class Parent {
@Persistent
private String name;
@Elements(mappedBy = "parent", dependent = "true")
private List<Children> children;
}
@PersistenceCapable
public class Child {
@Persistent
private String name;
@Persistent
private Parent parent;
}
Cascading deletes work fine. I can delete a parent and all its children will be removed from the data store.
If I query the data store for a particular child and have that query delete it, then the child is removed from the table of Child objects but its Parent's list of children will contain a null entry.
I guess this is a fairly dumb question but is there a开发者_如何学运维 way to get JDO to update the parent's list on deletion of a child or do I have to do this myself?
Thanks for your replies.
I recommend db4o without the DataNucleus layer. It is just getting in the way of a better performing soluton. We've done testing and found that if you use db4o directly it performs much better and uses less resources.
精彩评论