0

I'm getting a NullPointer here, obviously because my query is not well formed. I was under the impression I could query for a Pointer column in my Class by just providing an object that matches it. Why doesn't the current user suffice?

    ParseUser currentUser = ParseUser.getCurrentUser();

    ParseQuery<ParseObject> requestsQuery = ParseQuery.getQuery("Request");
        requestsQuery.whereEqualTo("author", currentUser);
        requestsQuery.findInBackground(new FindCallback<ParseObject>() {
            @Override
            public void done(List<ParseObject> requestList, ParseException e) {
                if (e == null) {
                    log.info(requestList.toString());

                }

            }
     });

NullPointer:

[WARNING] 
java.lang.NullPointerException
    at com.nnit.automation.controller.IndexController$1.done(IndexController.java:58)
    at org.parse4j.ParseQuery$FindInBackgroundThread.run(ParseQuery.java:623)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

enter image description here

Martin Erlic
  • 5,467
  • 22
  • 81
  • 153
  • 1
    it should work. I checked your code with similar Scheme. There will be two problems on there. 1- requestList may be null so check requestList size or null. 2- Problem may about ParseUser.getCurrentUser(). May be it is null or error occurs when getting current user data. Sometimes, re-installing or re-login helps. – iravul Apr 03 '17 at 14:31
  • What worked for me was changing my query constraint to ``query.whereContains`` and using the objectId of the current user: ``requestsQuery.whereContains("author", currentUser.getObjectId());``... – Martin Erlic Apr 03 '17 at 15:50

0 Answers0