使用parse.com,我想从服务器获取新消息并将其固定在本地。我在Android 5.0.1和Parse-1.8.1上。
@Override
public void fetchMessagesFromServer(final Conversation conversation, Date newerThanDate, final Callback<List<Message>> callback) {
ParseQuery<Message> parseQuery = ParseQuery.getQuery(Message.class);
parseQuery.whereEqualTo(Message.CONVERSATION, conversation);
parseQuery.whereGreaterThan(Message.CREATED_AT, newerThanDate);
parseQuery.orderByAscending(Message.CREATED_AT);
parseQuery.findInBackground(new FindCallback<Message>() {
@Override
public void done(final List<Message> messages, ParseException e) {
if (e != null) {
callback.error(e);
} else {
Message.pinAllInBackground(conversation.getObjectId(), messages, new SaveCallback() {
@Override
public void done(ParseException e) {
if (e != null) {
callback.error(e);
} else {
callback.success(messages);
}
}
});
}
}
});
}
获取按预期工作,我得到6个Message
个对象,都有一个目标。但是,使用Message.pinAllInBackground(String name, List<Message> objects, SaveCallback saveCallback)
将其固定为com.parse.ParseException: bolts.AggregateException: There were 6 exceptions.
AggregateException.causes
包含6个相同的例外:
UNIQUE constraint failed: ParseObjects.className, ParseObjects.objectId (code 2067)
虽然我理解由className和objectId组成的唯一约束失败,但我无法看到我做错了什么。检查所有6个Message对象显示所有objectId都不同。有没有人看到问题?这是一个错误吗?