0
と一緒に使用できません。Ref <> @Loadでの使用に問題があります。基本的にはObjectifyのWebサイトからロード・グループで@Loadアノテーションをテストするためにコピー・ペーストを作成しました。Objectify Ref <> with @Loadはofy()。load()。group()
@Entity
public static class Thing {
public static class Partial {}
public static class Everything extends Partial {}
public static class Stopper {}
@Id Long id;
@Load(Partial.class) Ref<Other> withPartial;
@Load(Everything.class) Ref<Other> withEveryhthing;
@Load(unless=Stopper.class) Ref<Other> unlessStopper;
public Ref<Other> getWithPartial() {
return withPartial;
}
public void setWithPartial(Ref<Other> withPartial) {
this.withPartial = withPartial;
}
public Ref<Other> getWithEveryhthing() {
return withEveryhthing;
}
public void setWithEveryhthing(Ref<Other> withEveryhthing) {
this.withEveryhthing = withEveryhthing;
}
public Ref<Other> getUnlessStopper() {
return unlessStopper;
}
public void setUnlessStopper(Ref<Other> unlessStopper) {
this.unlessStopper = unlessStopper;
}
}
次に、次のコードを書きました。
Other other = new Other();
Key<Other> otherKey = ofy().save().entity(other).now();
Thing thing = new Thing();
thing.setWithPartial(Ref.create(otherKey));
Key<Thing> thingKey = ofy().save().entity(thing).now();
Thing t = ofy().load().key(thingKey).now();
System.out.println("Is loaded: " + t.getWithPartial().isLoaded());
y()。load()。group(Partial.class).key(thingKey).now();他のエンティティはまだセッションにロードされます。しかし、ドキュメンテーションでは、ロードするグループクラスが必要です。