I'm using the parse.com Android SDK. I have a table Foo with a pointer to the table Bar, and classes Foo and Bar that extend ParseObject. In Foo, I have this method:
public void getBar(final GetCallback<Bar> callback){
getParseObject("bar").fetchIfNeededInBackground(callback);
}
This is the error I get:
java.lang.ClassCastException: com.parse.ParseObject cannot be cast to com.package.Bar
getParseObject returns a ParseObject, but fetchIfNeededInBackground won't return the subclass, just ParseObject. The documentation describes it so:
public final <T extends ParseObject> void fetchIfNeededInBackground(GetCallback<T> callback)
To me, that seems to indicate that it will give back a subclass of ParseObject according to the type of callback object you pass in. On the other hand, fetch says:
public <T extends ParseObject> T fetch()
And I don't see how you can supply a subtype to that method. Do I need to call a fetch method on an instance of Bar in order for this to work? If so, how do I get a Bar from my Foo? I think I could call getParseObject, create a new Bar, and copy the values from one to the other, but that's really gross and I'm hoping I don't have to shower every time I see this code.