mark
(Mark)
May 2, 2016, 3:39pm
1
Im trying make a Friend system by creating a column for a one to Many User Relationship.
When im trying to save the BackendlessUser array list with the user its returning the Faults responses
Object[] currentfriendObj = (Object[]) user.getProperty("friends");
if (currentfriendObj .length > 0) {
currentfriends = (BackendlessUser[]) currentfriendObj ;
if (currentfriends.length > 0) {
newfriends = new BackendlessUser[currentfriends.length + 1];
for (int i = 0; i < currentfriends.length; i++) {
newfriends = currentfriends;
}
newfriends[newfriends.length - 1] = newUser;
}
user.setProperty("friends", newfriends);
Backendless.Persistence.save(user, new AsyncCallback<BackendlessUser>() {//NOT SAVING
@Override
public void handleResponse(BackendlessUser backendlessUser) {
Log.i("hope", "SAVED!!!");
}
@Override
public void handleFault(BackendlessFault backendlessFault) {
Log.i("hope", "ERROR!!!!");
}
});
Please provide the details of what the Fault object contains. We’d need to know the following:
error code
error message
the "detail" string
All of these are documented here:
https://backendless.com/documentation/data/android/error_handling.htm
mark
(Mark)
May 2, 2016, 3:58pm
3
error code : 1020
message :Missing ___class property for entity: friends
what you mean by the “detail” string
The “detail” string can be obtained using the getDetail() method on the fault object.
Please make sure you’re using the latest build of the Backendless library.
mark
(Mark)
May 2, 2016, 5:32pm
5
the detail string is “null”
and i am using latest libarary
What if you change the code to:
user.setProperty("friends", Arrays.asList( newfriends ) );
What is the type of the “user” object?
try changing this:
Backendless.Persistence.save(user, new AsyncCallback<BackendlessUser>() {
to this:
Backendless.Persistence.of( BackendlessUser.class ).save(user, new AsyncCallback<BackendlessUser>() {
Does the user object you save have any other properties?
Ok, what does “newUser” object look like? Is it a registered user or just an object you created on the client side?
mark
(Mark)
May 2, 2016, 7:53pm
15
its a registered user
String whereClause = "name =" + "\'" + secondUser + "\'";
BackendlessDataQuery query = new BackendlessDataQuery();
QueryOptions queryOptions = new QueryOptions();
query.setWhereClause(whereClause);
queryOptions.addRelated("friends");
queryOptions.addRelated("friends.RELATION-OF-RELATION");
query.setQueryOptions(queryOptions);
Backendless.Persistence.of(BackendlessUser.class).find(query, new AsyncCallback<BackendlessCollection<BackendlessUser>>() {
@Override
public void handleResponse(BackendlessCollection<BackendlessUser> secUser) {
newUser = secUser.getCurrentPage().get(0);
Thanks. What is your application id?