Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有Objectify 5的多态性_Java_Google App Engine_Objectify - Fatal编程技术网

Java 带有Objectify 5的多态性

Java 带有Objectify 5的多态性,java,google-app-engine,objectify,Java,Google App Engine,Objectify,我有以下课程: @Entity(name = "Post") public abstract class PostRecord { @Id private Long id; private String field1; } @Subclass(name = "Bulletin") public class BulletinRecord extends PostRecord { private String field2; } @Subclass(name

我有以下课程:

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

    @Id
    private Long id;
    private String field1;
}

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

    private String field2;
}

@Subclass(name = "Session")
public class SessionRecord extends PostRecord {

    private String field3;
}
如何获取所有公告或所有会话?

下面的代码可以正常工作,并返回包含所有公告和会话的帖子列表:

ofy().load().type(PostRecord.class).list();
但我只需要公告或会话,当我尝试下面的代码时,我会得到一个空列表:

ofy().load().type(BulletinRecord.class).list();
ofy().load().type(SessionRecord.class).list();

您需要索引子类鉴别器

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

GAE中的所有筛选(如子类筛选)都需要索引;指数有成本;Objectify要求您选择此成本。

您需要为子类鉴别器编制索引

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

GAE中的所有筛选(如子类筛选)都需要索引;指数有成本;Objectify要求您选择此成本。

您需要为子类鉴别器编制索引

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

GAE中的所有筛选(如子类筛选)都需要索引;指数有成本;Objectify要求您选择此成本。

您需要为子类鉴别器编制索引

@Subclass(name = "Bulletin", index = true)
public class BulletinRecord extends PostRecord {
}
GAE中的所有筛选(如子类筛选)都需要索引;指数有成本;Objectify要求您选择此成本