Saving User Relation - "Cannot save entity with primitive collection property"

I want to save an object which has a relation to the user table:

 @IBAction func saveCommunityNameTapped(sender: AnyObject) {

        

        let user = self.backendless.userService.currentUser

        let selectedCompetition = allCompetitions[self.pickerView.selectedRowInComponent(0)]

        

        if (user == nil) {

            print("empty")

            

        }

        else { print(user.description) }

        

        //check if textfield is empty

        if (nameOfCommunityTextField.text != "") {

            

            let communityItem = Community(

                name: self.nameOfCommunityTextField.text!,

                welcomeText: self.welcomeTextBox.text!,

                members: [user],

                admin: user,

                competition: selectedCompetition

            )

        

            let dataStore = backendless.data.of(Community.ofClass())

            

            // save object asynchronously

            dataStore.save(

                communityItem,

                response: { (result: AnyObject!) -> Void in

                    let obj = result as! Community

                    print("Contact has been saved: \(obj.name)")

                },

                error: { (fault: Fault!) -> Void in

                    print("Server reported an error: \(fault)")

            })

            

            dismissViewControllerAnimated(true, completion: nil)

        

        } else {

            

            displayAlertWith("Please enter the name of your new Community")

        }

    }



I get:

Server reported an error: FAULT = ‘8044’ [Cannot save entity with primitive collection property adminOf] <Cannot save entity with primitive collection property adminOf>

Which is weird, because I don´t have that column in the user table.

My Community object looks like this:

class Community: NSObject {

    

    var name: String?

    var welcomeText: String?

    var admin: BackendlessUser?

    var member: [BackendlessUser]?

    var competition: Competition?

    




    init(name: String, welcomeText: String, members: [BackendlessUser], admin: BackendlessUser, competition: Competition) {

        

        self.name = name

        self.welcomeText = welcomeText

        self.member = members

        self.admin = admin

        self.competition = competition

    }

    

    override init() {

        

        super.init()

    }

}



Hope you can help me.

Thanks

Hi, Norman. We’ll check it out and get back to you.

I just printed the user description to console - adminOf seems to be part of my user class. I deleted that column a couple of days ago - maybe this could be related?

&lt;BackendlessUser&gt; {

    "__meta" = "{\"relationRemovalIds\":{},\"selectedProperties\":[\"created\",\"ownerId\",\"__updated__meta\",\"password\",\"adminOf\",\"imageURL\",\"name\",\"___class\",\"alias\",\"memberOf\",\"updated\",\"objectId\",\"email\"],\"relatedObjects\":{}}";

    adminOf =     (

    );

    alias = "norm\U00c4n";

    created = "2016-04-12 12:09:17 +0000";

    email = "xxx";

    imageURL = 500;

    lastLogin = "2016-04-12 12:09:18 +0000";

    memberOf =     (

    );

    name = "&lt;null&gt;";

    objectId = "5E8C40C8-160D-7200-FF6D-D969AA2ECA00";

    ownerId = "D78C479B-70FF-894D-FFEC-8BD2B3C55A00";

    updated = "&lt;null&gt;";

    "user-token" = "78D3BEFA-EFDC-D114-FF72-2BD13DFBE600";

}

So, is this fixed the issue?

Norman,

If you deleted the column “adminOf” and there is no trace of it in the code and on the backend, I cannot think of a way this error would continue to occur.

Regards,
Mark

but it does. i deleted the column a couple of days ago but the exception still exists. i dont know why the description still shows that property (same for memberOf)

Could you please let me know your application id?

application id 181FC865-17F8-A305-FF94-10DD5C2F9600

Norman, I connected to your app (you can see me in the Manage > App Settings > Dev team) and retrieved a user object. Here’s what I got (I changed email address).

<BackendlessUser> {

"___class" = Users;

"__meta" = "{\"relationRemovalIds\":{},\"selectedProperties\":[\"__updated__meta\",\"password\",\"created\",\"imageURL\",\"name\",\"___class\",\"alias\",\"ownerId\",\"updated\",\"objectId\",\"email\"],\"relatedObjects\":{}}";

"__updated__meta" = "{\"relationRemovalIds\":{},\"selectedProperties\":[\"lastLogin\",\"userStatus\",\"created\",\"imageURL\",\"name\",\"___class\",\"alias\",\"ownerId\",\"updated\",\"objectId\",\"email\",\"__meta\"],\"relatedObjects\":{}}";

alias = Norm;

created = "2016-04-08 15:26:47 +0000";

email = "XXXXXXXXXXX@gmail.com";

imageURL = "&lt;null&gt;";

lastLogin = "2016-04-18 19:28:55 +0000";

name = "&lt;null&gt;";

objectId = "FC3E2C5B-677F-0A40-FFD9-56613C9EF900";

ownerId = "FC3E2C5B-677F-0A40-FFD9-56613C9EF900";

password = "&lt;null&gt;";

updated = "&lt;null&gt;";

userStatus = ENABLED;

}

Apparently this was caching issue - Resetting content & settings of my simulator solved the problem.

Very sorry for the inconvinience - and thanks!