Support Topics Documentation Slack YouTube Blog

Two Step one to many retrieval Error


(Issah Mudasir) #1

I get this Error below when i tried using the one to many relation data retrieval. what could be the reason for the error

Find my sample code below:

pizzato [13 hours ago]
LoadRelationsQueryBuilder loadRelationsQueryBuilder;
loadRelationsQueryBuilder = LoadRelationsQueryBuilder.of(hostelImages.class);
loadRelationsQueryBuilder.setRelationName(“imageSlide”);

   String parentObjectId = "306927CB-AF54-8E9C-FFA3-EFAE53A2B600";
   Backendless.Data.of("hostel").loadRelations(parentObjectId,
           loadRelationsQueryBuilder, new AsyncCallback<List<hostelImages>>() {
               @Override
               public void handleResponse(List<hostelImages> response) {
                   for (int i = 0; i < response.size(); i++){
                       *//*String imgUrl = response.get(i).getImage();
                       TextSliderView textSlider = new TextSliderView(hostelInfo.this);
                       textSlider.description(response.get(i).getName());
                       textSlider.image(imgUrl);
                       Toast.makeText(hostelInfo.this, "Hi: " + imgUrl, Toast.LENGTH_SHORT).show();
                       //slider.addSlider(textSlider);*//*


          }
                   Toast.makeText(hostelInfo.this, "Size: "+ response.size(), Toast.LENGTH_SHORT).show();

               }

               @Override
               public void handleFault(BackendlessFault fault) {
                   Toast.makeText(hostelInfo.this, "Error :" + fault.getMessage(), Toast.LENGTH_LONG).show();
               }
           });


(Mark Piller) #2

Hello,

What is the data type of the imageSlide column?

Regards,
Mark


(Issah Mudasir) #3

The Data type is Data Object relationship. See screenshot below


(Mark Piller) #4

Can you run a search for the following query in the Hostel table?:
objectId = '306927CB-AF54-8E9C-FFA3-EFAE53A2B600'
Please a screenshot of that. Then navigate to the related objects in the imageSlide column and post another screenshot of that.

Thanks!


(Issah Mudasir) #5

Thanks for your swift reply. I have done what you asked. my search brought a result.
see the screen shots below.


(Issah Mudasir) #6

Another screenshot when i click on the related objects


(Issah Mudasir) #7

I have solved the problem. The Issue had to do with the Parent table name. I didnt spell it correctly in my client code it was “Hostel” and i typed “hostel” instead. Thanks for the support.


(Mark Piller) #8

Btw, I noticed you have the auto-load enabled for the imageSlide column. If you’re retrieving hostelImage objects with the two-step retrieval, I would recommend turning the auto-load off.

Regards,
Mark