So I have a PictureModelNew (terrible temp name I know) table that has a relation to the Brands table called BrandID. At the moment the Brands table has one field, BrandName. I would like to retrieve a PictureModelNew and then access the associated Brand/BrandName. This is the code I’m using:
BackendlessDataQuery query = new BackendlessDataQuery();
QueryOptions queryOptions = new QueryOptions();
queryOptions.addRelated( “BrandID” );
query.setQueryOptions(queryOptions);
Backendless.Data.of( PictureModelNew.class ).find(query, new AsyncCallback<BackendlessCollection<PictureModelNew>>() {
@Override
public void handleResponse(BackendlessCollection<PictureModelNew> pictureModelNewBackendlessCollection) {
BackendlessCollection<PictureModelNew> pics = pictureModelNewBackendlessCollection;
PictureModelNew pic = pics.getCurrentPage().get(0);
String brandName = pic.getBrandID().getBrandName();
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
}
});
And then I get the backendlessFault message:
BackendlessFault{ code: ‘Internal client exception’, message: ‘Unable to adapt array to data type: class com.selfit.main.models.Brands’ }
Not sure what I’m doing wrong. Attached are screenshots of the Brands table and PictureModelNew table.
Thanks guys!