0

I'm using Google Endpoints with Objectify to create my server. Entity A is superclass of class B and class C; server side I've annotated like shown in Entity Polymorphism.

Then i write APIs for class A, and libraries to import in Android/iOs

Now, the problem is: client side i can retrieve class A, but i cannot access (using cast) to B and C properties

eg:

((B) A).getBProp();

obtaining a ClassCastException in java (end equivalent to objective-c).

The strange thing is that on Google Dashboard i can see the correct subclasses (^d and ^i) and also quering from google-apis-explorer i can retrieve all the fields of subclasses.

Is there someone using polymorphism in Objectify capable to help me? Thanks

stickfigure
  • 13,458
  • 5
  • 34
  • 50
obo
  • 3
  • 1
  • 3

1 Answers1

0

In the code you provided, you're casting an instance of class A (superclass) to class B. This will cause a ClassCastException unless you define a constructor for B that takes an instance of A.

Community
  • 1
  • 1
Nick
  • 3,581
  • 1
  • 14
  • 36