JDO 可以一次获取数据库模型的所有子模型吗?
喜欢:
class Parent {
@Persistent(mappedBy="parent")
private Set<Children> children;
}
class Children {
@Persistent
private Parent parent;
@Persistent
private String name;
}
就我而言,我有大量的 parent ,我可以立即获取。然后访问他们的 child 需要花费很多时间,因为他们是懒惰地获取的。
JDO(Datanucleus)是否支持与父级一起立即获取?
我还尝试使用另一个查询独立地获取所有子项,然后将它们放入二级缓存中,但仍然获取它们(也许jdo不知道它们的关系?因为ForeignKey(parent-id)还没有一开始就被获取了?)
有什么想法可以更快地读取数据结构吗?
干杯,
一月
最佳答案
您正在使用 Fetch Groups ?您的子类可能不在默认的获取组中。
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
关于java - 使用 JDO (Datanucleus) 急切地获取子项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2951786/