Hi
I’m trying to add a relation between two objects but I keep getting a syntax error that the method cannot be resolved. When I tried the AsyncCallback with Void, the syntax error went away but I got an class cast exception when I ran the program. I’m confused.
I’m using java for android.
ArrayList<BackendlessUser> addressCollection = new ArrayList<BackendlessUser>();
addressCollection.add( Backendless.UserService.CurrentUser() );Backendless.Data.of( Cart.class ).addRelation( cart, "user:User:1", addressCollection, new AsyncCallback<Integer>()
{
@Override
public void handleResponse(Integer response) {
}
@Override
public void handleFault(BackendlessFault fault) {
}
} );
Hi
First of all you need to change from “user:User:1” to “user:Users:1”.
Regarding the remaining part of the code - everything looks ok. I’ve created the same data structure as yours - and everything worked for me.
Make sure to do the following:
- when adding relation - make sure that the object is found first (if it already exists) or saved in backendless (if you’re creating the new object)
- to set current user as related - user should be logged in
- make sure that you are using the correct version of SDK, I’ve received similar exceptions when used your code with old SDK. If your app is on the 4.0 environment - you should use corresponding SDK (please check in pom.xml located in backendless.jar)
Regards Anton
Hi Anton,
Thank you, I changed the backendless to 4.0.0 beta-3 and it worked fine after that.