objectify由id加载@subclass

时间:2016-01-11 02:25:57

标签: java google-app-engine objectify

我有这些课程:

@Entity(name = "Post")
public abstract class PostRecord {

    @Id
    private Long id;
}


@Subclass(name = "Bulletin", index = true)
public class BulletinRecord extends PostRecord {

}

我试图通过id获取bulletinRecord,但我总是得到null。 这是我的尝试:

ofy().load().type(BulletinRecord.class).id(bulletinId).now();
ofy().load().type(PostRecord.class).id(bulletinId).now();
ofy().load().key(Key.create(Key.create(PostRecord.class , bulletinId), BulletinRecord.class, bulletinId)).now();
ofy().load().type(BulletinRecord.class).filter("id=", postId).first().now();
ofy().load().type(PostRecord.class).filter("id=", postId).first().now();

我可以在开发者控制台上看到我的记录,其中包含我想要获取的ID: bulletin record in datstore

有人能告诉我我做错了什么吗?感谢。

0 个答案:

没有答案
相关问题