有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JDO中的java应该是可传递的DefaultFetchGroup吗

对JDO来说是全新的,所以这可能是一个简单的问题,但我在文档中找不到它。 假设我有三个持久类:

 @PersistenceCapable(detachable = "true")
 public class Foo {

   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.INCREMENT)
   long id;
   @Persistent(defaultFetchGroup = "true")
   Set<Bar> bars;
 }

 @PersistenceCapable(detachable = "true")
 public class Bar {

   @PrimaryKey
   @Persistent(valueStrategy = IdGeneratorStrategy.INCREMENT)
   long id;
   @Persistent(defaultFetchGroup = "true")
   SubBar subBar;
 }

 @PersistenceCapable(detachable = "true")
 public class SubBar {

   @PrimaryKey
   String name;
 }

我把javax.jdo.option.DetachAllOnCommit设为true。 当我持久化/加载Foo并关闭事务时,是否也应获取Bar中的子条字段

当前,如果我尝试在分离的对象上访问它们,我会得到:

 javax.jdo.JDODetachedFieldAccessException: You have just attempted to access field "subBar" yet this field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.

DFG是否意味着不可传递,因此默认情况下不会获取字段中的字段,或者是否有其他设置控制这一点? 仅供参考,我尝试在Foo上设置FetchPlan的maxFetchDepth,但似乎没有任何改变


共 (0) 个答案