Backendless 4 : Related items Autoload

When loading a table with a column that has a (1:n) relationship the child items are not loaded even though the autoload is turned on
using below code will return 0 size , menus , is this how is it designed to work cause i thoght autoload meant loading child item in “find” response , or am it doing something wrong
thanks for the help and again this is an amazing product and things couldn’t be easier i love it



Backendless.Persistence.of(Restaurants.class).find(new AsyncCallback<List<Restaurants>>() {
@Override
public void handleResponse(List<Restaurants> restaurantsCollection) {
Log.d("Downloaded New " , String.valueOf(restaurantsCollection.get(0).getMenu().size()));
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.d("Fault " , backendlessFault.getMessage());
}
});



Hi Ibrahim,

I just tried auto-load in my app and it worked just fine. What is the name of the column for the menu in the Restaurants table? What does the Restaurants class look like?

Regards,
Mark

hello Mark thanks for replaying
the column in restaurant is called “menu”
http://support.backendless.com/public/attachments/1a0064c302c26c21b978fc6282b37552.png</img>

Thanks. Could you please post here the Restaurants class as well? By that I mean the source code…

// here is the restaurant class 
import com.backendless.Backendless;
import com.backendless.BackendlessUser;
import com.backendless.async.callback.AsyncCallback;
import com.backendless.geo.GeoPoint;
import com.backendless.persistence.BackendlessDataQuery;
import com.ibraimomer.red_dlvry.Models.Menus;

public class Restaurants
{
  private String maplocation;
  private String objectId;
  private String rating;
  private Double serialVersionUID;
  private java.util.Date updated;
  private Integer maxpendingorders;
  private String votes;
  private String banner;
  private String name;
  private String aboutrestaurant;
  private String phone;
  private String ownerId;
  private java.util.Date created;
  private String address;
  private String googleid;
  private String openninghours;
  private String maxorders;
  private java.util.List&lt;Menus&gt; menu;
  private BackendlessUser owner;
  public String getMaplocation()
  {
    return maplocation;
  }

  public void setMaplocation( String maplocation )
  {
    this.maplocation = maplocation;
  }

  public String getObjectId()
  {
    return objectId;
  }

  public String getRating()
  {
    return rating;
  }

  public void setRating( String rating )
  {
    this.rating = rating;
  }

  public Double getSerialVersionUID()
  {
    return serialVersionUID;
  }

  public void setSerialVersionUID( Double serialVersionUID )
  {
    this.serialVersionUID = serialVersionUID;
  }

  public java.util.Date getUpdated()
  {
    return updated;
  }

  public Integer getMaxpendingorders()
  {
    return maxpendingorders;
  }

  public void setMaxpendingorders( Integer maxpendingorders )
  {
    this.maxpendingorders = maxpendingorders;
  }

  public String getVotes()
  {
    return votes;
  }

  public void setVotes( String votes )
  {
    this.votes = votes;
  }

  public String getBanner()
  {
    return banner;
  }

  public void setBanner( String banner )
  {
    this.banner = banner;
  }

  public String getName()
  {
    return name;
  }

  public void setName( String name )
  {
    this.name = name;
  }

  public String getAboutrestaurant()
  {
    return aboutrestaurant;
  }

  public void setAboutrestaurant( String aboutrestaurant )
  {
    this.aboutrestaurant = aboutrestaurant;
  }

  public String getPhone()
  {
    return phone;
  }

  public void setPhone( String phone )
  {
    this.phone = phone;
  }

  public String getOwnerId()
  {
    return ownerId;
  }

  public java.util.Date getCreated()
  {
    return created;
  }

  public String getAddress()
  {
    return address;
  }

  public void setAddress( String address )
  {
    this.address = address;
  }

  public String getGoogleid()
  {
    return googleid;
  }

  public void setGoogleid( String googleid )
  {
    this.googleid = googleid;
  }

  public String getOpenninghours()
  {
    return openninghours;
  }

  public void setOpenninghours( String openninghours )
  {
    this.openninghours = openninghours;
  }

  public String getMaxorders()
  {
    return maxorders;
  }

  public void setMaxorders( String maxorders )
  {
    this.maxorders = maxorders;
  }

  public java.util.List&lt;Menus&gt; getMenu()
  {
    return menu;
  }

  public void setMenu( java.util.List&lt;Menus&gt; menu )
  {
    this.menu = menu;
  }

  public BackendlessUser getOwner()
  {
    return owner;
  }

  public void setOwner( BackendlessUser owner )
  {
    this.owner = owner;
  }


  public Restaurants save()
  {
    return Backendless.Data.of( Restaurants.class ).save( this );
  }


  public void saveAsync( AsyncCallback&lt;Restaurants&gt; callback )
  {
    Backendless.Data.of( Restaurants.class ).save( this, callback );
  }

  public Long remove()
  {
    return Backendless.Data.of( Restaurants.class ).remove( this );
  }


  public void removeAsync( AsyncCallback&lt;Long&gt; callback )
  {
    Backendless.Data.of( Restaurants.class ).remove( this, callback );
  }

  public static Restaurants findById( String id )
  {
    return Backendless.Data.of( Restaurants.class ).findById( id );
  }



  public static void findByIdAsync( String id, AsyncCallback&lt;Restaurants&gt; callback )
  {
    Backendless.Data.of( Restaurants.class ).findById( id, callback );
  }

  public static Restaurants findFirst()
  {
    return Backendless.Data.of( Restaurants.class ).findFirst();
  }



  public static void findFirstAsync( AsyncCallback&lt;Restaurants&gt; callback )
  {
    Backendless.Data.of( Restaurants.class ).findFirst( callback );
  }

  public static Restaurants findLast()
  {
    return Backendless.Data.of( Restaurants.class ).findLast();
  }



  public static void findLastAsync( AsyncCallback&lt;Restaurants&gt; callback )
  {
    Backendless.Data.of( Restaurants.class ).findLast( callback );
  }




}


That looks good. Was the Menus class also generated by Backendless?

yes they were both gernated by backendless 3 cause i cant use code genration in backendless 4 the page shows
(“The specified resource was not found”)
my app id is C5435E0B-3A8E-AD51-FFEE-A1DD23E2DE00

hello again i just tried change my code to this and it works yay , thanks for your help Mark

 DataQueryBuilder queryBuilder = DataQueryBuilder.create();
queryBuilder.setRelationsDepth(2);
 Backendless.Persistence.of(Restaurants.class).find(queryBuilder, new AsyncCallback&lt;List&lt;Restaurants&gt;>() {
     @Override
  

I fixed the code generation for you in the app - you should see all the generators as well as Project Templates (the button at the top of the console).

I also ran the code (without setRelationDepth) and it worked for me - got all the menus.

Cheers,
Mark

hello mark thanks for the sorry for the late reply i could finally use it 2 days ago with the relase of beta2 it works like a charm
thanks again ,