ThijsM
ThijsM

Reputation: 200

Parse error : Must specify a ParseObject class name

I have a problem when I want to retrieve ParseObjects from subclass containing a ParseRelation

When this code runs:

public void loadProjectsForCurrentUser() {
    User currUser = UserManager.Instance.CurrentUser;
    if (currUser != null) {
        currUser.Projects.Query.FindAsync().ContinueWith(t => {
            if(onProjectsLoaded != null) {
                onProjectsLoaded(new List<Project>(t.Result));
            }
        });
    } else {
        Debug.LogWarning("Trying to load projects while not logged in!");
    }
}

I get this error:

Error Message : Must specify a ParseObject class name when creating a ParseQuery. Parameter name: className

This is a part of my subclass:

[ParseFieldName(PARSE_VALUES.Projects)]
[CoherentProperty]
public ParseRelation<Project> Projects {
    get { return GetRelationProperty<Project>("Projects"); }
}

When the user logs in, I create a new instance of User, and I fetch the data like this:

User currUser = ParseUser.CreateWithoutData<User>(ParseUser.CurrentUser.ObjectId);
currUser.FetchIfNeededAsync().ContinueWith(userResult => {
  Debug.Log("Fetched User");
  currUser.Company.FetchIfNeededAsync().ContinueWith(companyResult => {
    Debug.Log("Fetched Company");
    UserManager.Instance.CurrentUser = currUser;
    ParentView.TriggerEvent("login", UserManager.Instance.CurrentUser);
    ProjectManager.Instance.loadProjectsForCurrentUser();
    if (onLogin != null)
        onLogin();
  });
});

I already found this page: https://www.parse.com/questions/error-when-querying-relational-data-in-unity

Here is the stack trace, might contain interesting information:

Error Message: Must specify a ParseObject class name when creating a ParseQuery. Parameter name: className Stack Trace: at Parse.ParseQuery1<Project>..ctor (string) <0x0008f> at Parse.ParseRelationBase.GetQuery<Project> () <0x0004e> at Parse.ParseRelation1.get_Query () <0x00039> at (wrapper dynamic-method) Parse.ParseRelation1<Project>.GetProperty (Parse.ParseRelation1&,Coherent.UI.Binding.Exporter) at Coherent.UI.Binding.UserDefinedTypeExporter1<Parse.ParseRelation1>.Export (Coherent.UI.Binding.Exporter,Parse.ParseRelation1<Project>) <0x00145> at Coherent.UI.Binding.Exporter.Export<Parse.ParseRelation1> (Parse.ParseRelation1<Project>) <0x00404> at (wrapper dynamic-method) User.GetProperty (User&,Coherent.UI.Binding.Exporter) <IL 0x00008, 0x00048> at Coherent.UI.Binding.UserDefinedTypeExporter1.Export (Coherent.UI.Binding.Exporter,User) <0x00145> at Coherent.UI.Binding.Exporter.Export (User) <0x00404> at (wrapper dynamic-method) Project.GetProperty (Project&,Coherent.UI.Binding.Exporter) at Coherent.UI.Binding.UserDefinedTypeExporter1<Project>.Export (Coherent.UI.Binding.Exporter,Project) <0x00145> at Coherent.UI.Binding.Exporter.Export<Project> (Project) <0x00404> at Coherent.UI.Binding.Exporter.ExportIList<Project> (Coherent.UI.Binding.Exporter,System.Collections.Generic.IList1) <0x00142> at (wrapper dynamic-method) Coherent.UI.Binding.Exporter.Exporter (Coherent.UI.Binding.Exporter,System.Collections.Generic.List1<Project>) <IL 0x00002, 0x0002c> at Coherent.UI.Binding.Exporter.Export<System.Collections.Generic.List1> (System.Collections.Generic.List1<Project>) <0x00404> at Coherent.UI.Binding.ViewExtensions.TriggerEvent<System.Collections.Generic.List1> (Coherent.UI.View,string,System.Collections.Generic.List1<Project>) <0x00073> at ProjectsWidget.onProjectsLoaded (System.Collections.Generic.List1) [0x0000c] in

But I can't seem to find the error... Anyone that can help?

Upvotes: 1

Views: 806

Answers (1)

ThijsM
ThijsM

Reputation: 200

Found it myself eventually.

It is a combination of problems between Coherent and Parse. Coherent tries to use the default constructor of ParseRelation, which I use in the User class as a property. But ParseRelation doesn't have a default constructor.

Coherent does expect a default constructor. I changed the following:

[ParseFieldName(PARSE_VALUES.Projects)]
[CoherentProperty]
public ParseRelation<Project> Projects {
    get { return GetRelationProperty<Project>("Projects"); }
}

into

[ParseFieldName(PARSE_VALUES.Projects)]
public ParseRelation<Project> Projects {
    get { return GetRelationProperty<Project>("Projects"); }
}

By removing the CoherentProperty tag, which I eventually don't need here, Coherent doesn't want to export ParseRelation, therefore I don't have the constructor error anymore!

Upvotes: 2

Related Questions