I'm trying to save the currentUser to the Pointer<_User> column in one of my classes. This is a library-specific problem (https://github.com/thiagolocatelli/parse4j/blob/master/src/main/java/org/parse4j/ParseUser.java). I'm just wondering if anybody else has had a similar issue.
ParseUser currentUser = ParseUser.currentUser;
ParseObject sentRequest = new ParseObject(ParseConstantsUtil.CLASS_REQUEST);
sentRequest.put("author", currentUser);
try {
sentRequest.save();
} catch (org.parse4j.ParseException e) {
e.printStackTrace();
}
pom.xml: I'm using the latest SNAPSHOT build as my Parse4J dependency.
<dependency>
<groupId>com.github.thiagolocatelli</groupId>
<artifactId>parse4j</artifactId>
<version>1.5-SNAPSHOT</version>
</dependency>
Exception:
ParseException [code=111, error=schema mismatch for Request.author; expected Pointer<_User> but got Pointer<users>]
at org.parse4j.command.ParseResponse.getParseError(ParseResponse.java:122)
at org.parse4j.command.ParseResponse.getException(ParseResponse.java:78)
at org.parse4j.ParseObject.save(ParseObject.java:486)
at com.test.automation.controller.RequestController.createRequestObject(RequestController.java:119)
at com.test.automation.controller.RequestController.saveRequest(RequestController.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
What's going wrong here?
It works when you query for the current user, but I think that's definitely an unnecessary additional call. I'd love to know why my first attempt fails...
ParseQuery<ParseObject> userQuery = ParseQuery.getQuery("_User");
userQuery.whereEqualTo("objectId", currentUser.getObjectId());
try {
List<ParseObject> userList = userQuery.find();
for (ParseObject author : userList) {
sentRequest.put("author", author);
try {
sentRequest.save();
} catch (org.parse4j.ParseException e) {
e.printStackTrace();
}
}
} catch (org.parse4j.ParseException e) {
e.printStackTrace();
}