java - Polymorphism with Objectify 5 -


i have classes:

@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; } 

how fetch bulletins or sessions?

this code below work fine , return post list bulletins , sessions:

ofy().load().type(postrecord.class).list(); 

but want bulletins or sessions, , when try code below, empty list:

ofy().load().type(bulletinrecord.class).list(); ofy().load().type(sessionrecord.class).list(); 

you need index subclass discriminators.

@subclass(name = "bulletin", index = true) public class bulletinrecord extends postrecord { } 

all filtering (such subclass filtering) in gae requires index; indexes have cost; objectify requires opt-in cost.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -