Type of property

Hello, I have next problem:

Object[] obj = (Object[]) user.getProperty(BackendlessUserProperties.FRIENDS);
It works well if that user doesn’t have any friends, but if he does, I got error for wrong type.

Could you post the actual error?

BackendlessFault{ code: ‘Server.Processing’, message: ‘java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException’ }

Try to debug your code and check which actual type you have inside of this property.

Thank you all . I am sorry , that was error in my code.

Actually, I have found bug in your service. When I add first user USING YOUR SITE for one raw in column (for example) Friends (That is many-to-many relationship) I am getting that error. When I add friend using my app everything is working fine. I think it is problem in how you init type of column.

We’d be really grateful if you could provide the exact steps on how to reproduce the error you receive.

I have made Column Friends that is in many-to-many relationship to USER. Next, I have registred two users using my app: user1 and user2 . After that I have made option ,add a friend" . That have code similar to this:

BackendlessUser user = Backendless.UserService.CurrentUser();
//Getting list of friends of CurrentUser and update it
Object[] obj = (Object[]) user.getProperty("friends");
if (obj.length > 0) {
 BackendlessUser[] friends = (BackendlessUser[]) obj;
 ArrayList<BackendlessUser> friendList = new ArrayList<BackendlessUser>();
 friendsList.addAll(Arrays.asList(friends));
 friendsList.add(clickedBackendlessUserItem);
 
 }
 user.setProperty("friends", friendsList);
 Backendless.UserService.update(user, new DefaultCallback<BackendlessUser>(context));} 
}
else {
 ArrayList<BackendlessUser> fiendsList = new ArrayList<BackendlessUser>();
 friendsList.add(clickedBackendlessUserItem);
 user.setProperty(BackendlessUserProperties.PENDINGS, pendingList);
 Backendless.UserService.update(user, new DefaultCallback<BackendlessUser>(context));} 
}

When I use my app to add first Friend from list of Users ,everything is working fine.
But, if I try to add User2 to User1’s column Friends using your Website Envirment my app crash and I got that error

Also how do you add a friend from our site and how does it fail?

A clicked on one raw (for User1 ) , and then selected one column “friends” and clicked on + sign. After that I selected User2 from list.

Also, I have this error when I tried to ,add two friends" from my app:

First, when I add one friend everything is fine and I get this in my console:

03-12 15:45:22.305 22481-22481/com.my.app I/BackendlessOK﹕ BackendlessUser{userStatus=ENABLED, updated=Sat Mar 12 15:45:22 CET 2016, gender=Man, pendings=[Lcom.backendless.BackendlessUser;@2364275, profilephotourl=[url=https://api.backendless.com/bd4a6dfc-fed0-c112-ffb2-a7cd12657900/v1/files/thrill_me_profile_photo/profile_l93ac10c6-9c59-412d-a2c8-a146f4397c10.jpg]https://api.backendless.com/bd4a6dfc-fed0-c112-ffb2-a7cd12657900/v1/files/thrill_me_profile_photo/profile_l93ac10c6-9c59-412d-a2c8-a146f4397c10.jpg[/url], lastLogin=null, __meta={"relationRemovalIds":{},"selectedProperties":["country","gender","birthyear","___savedRelations","profilephotourl","description","requests","ownerId","login","password","___class","relationship","__relatedschemausers","email","objectId","created","geopoint","friends","__meta","__relatedschemageopoint","person","pendings","interestedin","updated","username"],"relatedObjects":{"geopoint":["C149468F-577B-B549-FFCF-DEA328B7AD00"],"pendings":["C3C37788-6ED4-6EE6-FFC3-8524660FA500"]}}, login=l@l.com, birthyear=1900, ownerId=null, geopoint=GeoPoint{objectId='C149468F-577B-B549-FFCF-DEA328B7AD00', latitude=0.0, longitude=0.0, categories=[Default], metadata={}, distance=null}, friends=[Ljava.lang.Object;@14d8220a, objectId=62A4C043-5122-7533-FFB7-ACDBC1363C00, person=null, email=l@l.com, requests=[Ljava.lang.Object;@1821ba7b, interestedin=Men, description=hehehhe, country=Antarctica, username=l, relationship=null, created=Fri Mar 11 00:23:40 CET 2016}

But when I try to add second one I got this:

03-12 15:45:25.165 22481-22481/com.my.app E/BackendlessError﹕ BackendlessFault{ code: 'Server.Processing', message: 'java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: com.backendless.geo.model.GeoPoint cannot be cast to java.util.Map' }

Mladen,

Would it be possible for you to export your schema (data is optional) and email it to support@backendless.com? We’d like to reproduce the problem using the same data schema as in your app.

Regards,
Mark