parse4j
parse4j copied to clipboard
ParseQuery and ParseObject with ParseFile
Hello, I am trying to query a list of objects which contains a ParseFile, this is the failing code: ParseQuery<ParseObject> query=ParseQuery.getQuery("file_test"); System.out.println(query.find().size());
I am getting this exception: Exception in thread "main" java.lang.IllegalArgumentException: ParseFile must be saved before being set on a ParseObject. at org.parse4j.ParseObject.put(ParseObject.java:359)
Maybe find setData method should not be doing same validations as when we are creating the objects, I may be wrong on this :P
You need to save the parse object before you use it inside another one
On Sunday, April 6, 2014, Daniel Rodríguez Millán [email protected] wrote:
Hello, I am trying to query a list of objects which contains a ParseFile, this is the failing code: ParseQuery query=ParseQuery.getQuery("file_test"); System.out.println(query.find().size());
I am getting this exception: Exception in thread "main" java.lang.IllegalArgumentException: ParseFile must be saved before being set on a ParseObject. at org.parse4j.ParseObject.put(ParseObject.java:359)
Maybe find setData method should not be doing same validations as when we are creating the objects, I may be wrong on this :P
Reply to this email directly or view it on GitHubhttps://github.com/thiagolocatelli/parse4j/issues/6 .
"thiago:locatelli$gmail:com".replace(':','.').replace('$','@')
I don´t have access to the object at that moment, that is the only code in the app (apart from initialization), only a query over an entity so i don't have any previous ParseObject created.
I struggle with the same problem as well. I try to retrieve the existing objects that contain ParseFile column. The problem is inside ParseDecoder.decode which for incoming files:
if (typeString.equals("File")) {
return new ParseFile(jsonObject.optString("name"),
jsonObject.optString("url"));
}
uses the following constructor:
public ParseFile(String name, String url) {
this.name = name;
this.url = url;
}
This leaves all "deserialized" files in dirty state and causes problems. Any chance that it will be fixed soon?
I'm also getting this error when trying to query ParseObjects that contain ParseFiles. Will this be fixed, or is there a another way to handle this?
What I did for my project was to change:
public ParseFile(String name, String url) {
this.name = name;
this.url = url;
}
into this:
public ParseFile(String name, String url) {
this.name = name;
this.url = url;
this.dirty = false;
this.uplodated = true;
}
Personally, I have downloaded Parse4j sources and included it in my project. As far as I remember there were few other changes to this library as well.
Hi, I'm having this same problem. Is there a better work around then changing the source? I'm using this library from a mvn jar.
i ParseRelation<PItem> pItems = getRelation("PItems"); ParseQuery<PItem> fetchQuery = pItems.getQuery();
List<PItem> allPItems = null;
try {
allPItems = fetchQuery.find();
} catch (ParseException e) {
e.printStackTrace();
}
Exception in thread "pool-1-thread-1" java.lang.IllegalArgumentException: ParseFile must be saved before being set on a ParseObject. at org.parse4j.ParseObject.put(ParseObject.java:359) at org.parse4j.ParseObject.setData(ParseObject.java:725) at org.parse4j.ParseQuery.find(ParseQuery.java:499)
why is it trying to set an object when I'm trying to do a query?