Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't save current user as object in User Pointer column (Parse4J) #85

Open
SeloSlav opened this issue Apr 7, 2017 · 1 comment
Open

Comments

@SeloSlav
Copy link

SeloSlav commented Apr 7, 2017

Anybody else have a similar problem?

ParseUser currentUser = ParseUser.currentUser;

ParseObject sentRequest = new ParseObject("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?

@SeloSlav
Copy link
Author

SeloSlav commented Apr 7, 2017

It works when you query for the current user, but I think that's kind of unnecessary. 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();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant