在 GAE 数据库中添加子元素
我有一个持久对象,其中包含大量子元素。我正在尝试添加一个新元素,但为了检索列表,我花费了很多读取操作。如何在不获取列表的情况下添加此元素?
我正在使用这样的东西:
PersistenceManager pm = PMF.get().getPersistenceManager();
ObjectX obj= pm.getObjectById(ObjectX.class, id);
obj.getChildrenElements().add(newChild);
I have a persistent object that has a huge list of child elements. I'm trying to add a new element, but to retrieve the list i spent a lot of read operations. How can I add this elements without get the list?
I'm using something like this:
PersistenceManager pm = PMF.get().getPersistenceManager();
ObjectX obj= pm.getObjectById(ObjectX.class, id);
obj.getChildrenElements().add(newChild);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定还有其他方法可以做到这一点。相反,也许您可以尝试改变建立关系的方式。因此,您可以为每个子对象指定一个父对象,而不是为每个对象保留子对象列表。如果您不需要父级和子级属于同一实体组,则不必拥有此关系。
希望有帮助!
I am not sure there is another way to do this. Instead, maybe you could try to change the way you model the relationships. Thus, instead of keeping a list of children for each object, you could specify to each of the children a parent. This relationship doesn't have to be owned if you don't need the parents and the children to belong to the same entity group.
Hope that helps!