google cloud datastore - Persisting Collection<T> using Objectify4 on GAE -


i have been having issues persisting generic collection on google datastore using objectify4. e.g.

@entity class animalinfo {   @id   string id;   collection<animal> animals; }  @entitysubclass class cat extends animal {   string name; }  @entitysubclass class dog extends animal {   string name; }  @entity class animal {   @id   string id; } 

how can persist animalinfo class , retrieve again. have tried: objectify.save().entities(animalinfo).now(); while fetching again: objectify.load().type(animalinfo.class).id(animalinfo.id).get(); doesnt have name field corresponding extended class cat or dog.

this logical because animal class doesnt have field name. how work? generic interface ianimal (in place of animal class) better solution design-wise, doesnt work objectify needs concrete types.

any solution above problem??


thanks in advance.

shaun

to summarize, looks want collection of references polymorphic entities. this:

@entity class animalinfo {   @id string id;   collection<ref<animal>> animals = new arraylist<ref<animal>>(); } 

you need refs create reference other entities. use key too, less convenient. may want @load annotation.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -