I have a User and 2 custom objects, Business and Member. User has a bidirectional 1:N with Member. Member has a birirectional N:1 with Business. I have a business logic service which creates a new Business and initial Member for the logged in User. The relationships are all modelled as List<XXX>.
Creating and associating all the objects works fine. I then call
to save the object graph. Everything saves, but the response of the service is an exception. This seems to be from the result of the save being converted back into a Member instance to be returned from the service. The exception is
"java.lang.ClassCastException: [Lcom.mbaas.model.Member; cannot be cast to java.util.CollectionServiceException"
but the issue is the same. I’m guessing it’s something to do with the relationship from the User to the Member because it isn’t explicitly modelled where as there are specific classes for the other 2, both using List. I see I’m not allowed to subclass the BackendlessUser class.
Interestingly, though I see the User updated and the new Member and Business instances listed in the data browser, when I GET the user in the REST console the members list is empty.
I was also considering removing the relationship from User to Member and querying for Members whose user is the currently logged in user. I guess I can do that using the user objectId.
I’m no closer to understanding the cause of the issue, but at least I have a work around in that if I don’t set the relationship on the User and instead query for Member instances as I described above using the user.objectId then everything works to save and query back the instances.
I tried identical approach in my test app and could not reproduce the problem. There were a few fixes in our SDK for Android related to the problem you experienced. Could you please grab a copy of the latest build from the URL below and try it again? https://github.com/Backendless/Android-SDK/blob/master/out/backendless.jar