Search code examples
javaparse-platformparse4j

Query an object in Parse4J


I would like to know if it is possible to get an object, filtering by an attribute of an attribute class.

To be more specific, if I have:

Person<br>
-BasicInformation basicInformation

BasicInformation<br>
-Integer identificationNumber

I want to retrieve all Person that has identificationNumber = 9000000

I should do something like this:

ParseQuery<Person> personQuery = ParseQuery.getQuery(Person.class);    
personQuery.whereEqualTo("basicInformation.identificationNumber", 9000000);

But it does not work. Any ideas?


Solution

  • Thanks, everybody. I have resolved it.

    I had to do the followings steps.

    ParseQuery basicInformationQuery = ParseQuery.getQuery(BasicInformation.class);

    basicInformationQuery.whereEqualTo("identificationNumber", 9000000);

    And then

    ParseQuery personQuery = ParseQuery.getQuery(Person.class);
    personQuery.whereMatchesQuery("basicInformation", basicInformationQuery);

    personQuery.find();