Query an object in Parse4J

193 Views Asked by At

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?

2

There are 2 best solutions below

0
On BEST ANSWER

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();

0
On

You should be able to use relational queries. The main query would then query for all Person objects that match the result of your sub-query.

I quickly checked the docs of Parse4J and it does not seem to support this so you might need to either implement that yourself or call the REST-API directly.