使用 JDO (Datanucleus) 急切地获取子项

发布于 2024-09-03 22:31:25 字数 494 浏览 8 评论 0原文

JDO 可以一次获取数据库模型的所有子模型吗?

就像:

class Parent {
 @Persistent(mappedBy="parent") 
 private Set<Children> children;
}

class Children {
 @Persistent
 private Parent parent;
 @Persistent
 private String name;
}

就我而言,我有大量的父母,我可以立即获取。然后访问他们的孩子需要花费很多时间,因为他们是懒惰地获取的。

JDO(Datanucleus)是否支持与父级一起立即获取?

我还尝试使用另一个查询独立地获取所有子项,然后将它们放入二级缓存中,但它们仍然被获取(也许jdo不知道它们的关系?因为ForeignKey(parent-id)尚未在首先?)

有什么想法可以更快地读取数据结构吗?

干杯,

Can JDO fetch all children of a database model at once?

Like:

class Parent {
 @Persistent(mappedBy="parent") 
 private Set<Children> children;
}

class Children {
 @Persistent
 private Parent parent;
 @Persistent
 private String name;
}

In my case, I have a large number of parents which I fetch at once. Accessing their children then takes a lot of time because they are fetched lazily.

Does JDO (Datanucleus) support their fetching at once, togehter with the parents?

I also tried to fetch all children independantly with another query and put them into the Level2 cache afterwards, but still they are fetched (maybe jdo doesn't know about their relationship? Because the ForeignKey (parent-id) hasn't been fetched at first?)

Any ideas how to read the data structure faster?

Cheers,

Jan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

热鲨 2024-09-10 22:31:26

您是否使用获取组?您的子类可能不在默认的获取组中。

当从
JDO 的数据存储通常不是全部
立即检索字段。这
是因为为了效率目的
只有特定的字段类型是
在初始访问中检索
对象,然后任何其他对象都是
访问时检索(惰性
加载中)。字段组是
加载的称为获取组

Are you using Fetch Groups? Your Child classes are probably not in the default fetch group.

When an object is retrieved from the
datastore by JDO typically not all
fields are retrieved immediately. This
is because for efficiency purposes
only particular field types are
retrieved in the initial access of the
object, and then any other objects are
retrieved when accessed (lazy
loading). The group of fields that are
loaded is called a fetch group

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