在 GAE 数据库中添加子元素

发布于 2024-12-15 07:26:57 字数 272 浏览 5 评论 0原文

我有一个持久对象,其中包含大量子元素。我正在尝试添加一个新元素,但为了检索列表,我花费了很多读取操作。如何在不获取列表的情况下添加此元素?

我正在使用这样的东西:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

巷雨优美回忆 2024-12-22 07:26:57

我不确定还有其他方法可以做到这一点。相反,也许您可​​以尝试改变建立关系的方式。因此,您可以为每个子对象指定一个父对象,而不是为每个对象保留子对象列表。如果您不需要父级和子级属于同一实体组,则不必拥有此关系。

希望有帮助!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文