gpt4 book ai didi

java - 查询 ParseObject

转载 作者:太空狗 更新时间:2023-10-29 22:54:42 29 4
gpt4 key购买 nike

我正在尝试使用 Parse 查询获取对象。

这是我的代码:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Conference");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
// Results were successfully found from the local datastore.
} else {
showLog(e.toString());
}
}
});

我收到这个错误:

com.parse.ParseException: java.lang.IllegalStateException: ParseObject has no data for 'objectId'. Call fetchIfNeeded() to get the data.

顺便说一句,我的 Conference 类包含指针。

最佳答案

如果您直接从 Parse 查询,您可以:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Conference");
...
query.include("name_of_the_column_containing_a_pointer");
query.include("another_pointer_column");
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
// You can now access the pointers specified in the include
} else {
showLog(e.toString());
}
}
});

否则,如果您正在查询本地数据存储:

ParseQuery<ParseObject> query = ParseQuery.getQuery("Conference");
...
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> results, ParseException e) {
if (e == null) {
ParseObject parseObject = results.get(0); // Get the object
parseObject.fetchIfNeededInBackground(new GetCallback<ParseObject>() {
public void done(ParseObject result, ParseException e) {
if (e == null)
// Do something with result
}
}
} else {
showLog(e.toString());
}
}
});

关于java - 查询 ParseObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33802581/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com