删除 JDO 中的子实体
我想知道JDO中是否可以实现以下操作。
我的父类和子类之间有 1-N 关系。所以我的课程看起来
@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;
}
级联删除工作正常。我可以删除父级,其所有子级都将从数据存储中删除。
如果我在数据存储中查询特定子对象并让该查询将其删除,则该子对象将从子对象表中删除,但其父对象的子对象列表将包含空条目。
我想这是一个相当愚蠢的问题,但是有没有办法让 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我推荐没有 DataNucleus 层的 db4o。它只是妨碍了性能更好的解决方案。我们已经进行了测试,发现如果直接使用 db4o,它的性能会更好,并且使用的资源也会更少。
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.