ihave a table RESTAURANTS with column Menu which is a data relation object (one to many) with Table MENUS
Doing this in #Backendless 3
Backendless.Persistence.of(Restaurants.class).find(new AsyncCallback<BackendlessCollection<Restaurants>>() {
@Override
public void handleResponse(BackendlessCollection<Restaurants> restaurantsCollection) {
restaurants.addAll(restaurantsCollection.getData());
for(int i = 0 ; i < restaurantsCollection.getData().size() ; i ++) {
Log.d("Menus Count", String.valueOf(restaurantsCollection.getData().get(i).getMenu().size()));
}
Will retrive the count for menus count Corretly
but doing the same in Backendless 4 will return 0
#Backendless 4
Backendless.Persistence.of(Restaurants.class).find(new AsyncCallback<List<Restaurants>>() {
@Override
public void handleResponse(List<Restaurants> restaurantsCollection) {
restaurants.addAll(restaurantsCollection);
for(int i = 0 ; i < restaurantsCollection.size() ; i ++) {
Log.d("Menus Count", String.valueOf(restaurantsCollection.get(i).getMenu().size()));
}
Thanks for the help
do you have “auto-load” enabled for the “menu” column in the Restaurant table?
Yes Ofcourse , yes and i also made a new a table with same relation and tried the same precdure , i got the same result , 0 count ,
Just to make sure, so we can reproduce the error - you’re doing it in Android now (your previous posts were for .net), is that correct?
Yes am doing it in android , , only way i could get the data was though 2 step relationship retrieval
like this
for (int i = 0; i < restaurants.size(); i++) {
LoadRelationsQueryBuilder<Menus> loadRelationsQueryBuilder;
loadRelationsQueryBuilder = LoadRelationsQueryBuilder.of(Menus.class);
loadRelationsQueryBuilder.setRelationName("menu");
String ObjectId = restaurants.get(i).getObjectId();
final int finalI = i;
Backendless.Persistence.of(Restaurants.class).loadRelations(ObjectId,
loadRelationsQueryBuilder, new AsyncCallback<List<Menus>>() {
@Override
public void handleResponse(List<Menus> menus) {
ArrayList<Menus> menuses = new ArrayList<Menus>();
for (int x = 0; x < menus.size(); x++) {
menuses.add(menus.get(x));
}
restaurants.get(finalI).setMenus(menuses);
}
@Override
public void handleFault(BackendlessFault fault) {
}
}
);
, but i prefer the auto-load way as its not a large set of data
Ps
and i also tried it in .net same result
thank you for your help
Hi Ibrahim,
Please verify whether the issue still persists, there were a few changes on our side since then.