ParseQuery 总是出现异常
ParseQuery get exception all the time
我正在尝试从具有以下列的 table 中检索行:
- objectId
- InvitedId
- PartyId
- 即将到来
- 创建时间
- 更新时间
ACL
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("PartiesInvites");
ArrayList<ParseObject> partiesId = new ArrayList<>();
for (int i = 0; i < mParties.size(); i++) {
partiesId.add(mParties.get(i).getObjectId());
Log.d("UU-UPIL", "partyId = " + partiesId.get(i));
}
query.whereContainsAll("PartyId", partiesId);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> partiesInvitationsIn, ParseException e) {
Log.d("UU-UPIL", "finding parties invitations");
if (e == null) {
for (int i = 0; i < partiesInvitationsIn.size(); i++) {
Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId());
}
mPartiesInvitations = partiesInvitationsIn;
Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size()));
} else {
e.printStackTrace();
}
}
});
这是我遇到的异常
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ com.parse.ParseException: java.lang.IllegalStateException: A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.Parse.run(Parse.java:971)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Looper.loop(Looper.java:212)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5135)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ Caused by: java.lang.IllegalStateException: A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.createWithoutData(ParseObject.java:257)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.fromJSON(ParseObject.java:524)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.fromJSON(ParseObject.java:499)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.convertFindResponse(ParseQuery.java:386)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.access0(ParseQuery.java:80)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.then(ParseQuery.java:567)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.then(ParseQuery.java:558)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at bolts.Task.run(Task.java:444)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
我尝试将查询从 "whereContainsAll" 更改为 "whereContainedIn",但我一直收到相同的异常。我的代码有什么问题吗!?
改变这个
query.whereContainsAll("PartyId", partiesId);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> partiesInvitationsIn, ParseException e) {
Log.d("UU-UPIL", "finding parties invitations");
if (e == null) {
for (int i = 0; i < partiesInvitationsIn.size(); i++) {
Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId());
}
mPartiesInvitations = partiesInvitationsIn;
Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size()));
} else {
e.printStackTrace();
}
}
});
对此
query.whereContainsAll("PartyId", partiesId);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> partiesInvitationsIn, ParseException e) {
Log.d("UU-UPIL", "finding parties invitations");
if (e == null) {
for (int i = 0; i < partiesInvitationsIn.size(); i++) {
Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId());
}
mPartiesInvitations = partiesInvitationsIn;
Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size()));
} else {
e.printStackTrace();
}
}
});
基本上就是在done方法前加一个@Override
A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
我不确定您的代码中是否有一个来自 parseObject 的子类用于将数据库条目放入其中,但是当您修改该子类的构造函数中的项目时会引发此异常
Ensure that your subclass has a public default (i.e. zero-argument) constructor. You must not modify any ParseObject fields in this constructor.
我正在尝试从具有以下列的 table 中检索行:
- objectId
- InvitedId
- PartyId
- 即将到来
- 创建时间
- 更新时间
ACL
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("PartiesInvites"); ArrayList<ParseObject> partiesId = new ArrayList<>(); for (int i = 0; i < mParties.size(); i++) { partiesId.add(mParties.get(i).getObjectId()); Log.d("UU-UPIL", "partyId = " + partiesId.get(i)); } query.whereContainsAll("PartyId", partiesId); query.findInBackground(new FindCallback<ParseObject>() { public void done(List<ParseObject> partiesInvitationsIn, ParseException e) { Log.d("UU-UPIL", "finding parties invitations"); if (e == null) { for (int i = 0; i < partiesInvitationsIn.size(); i++) { Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId()); } mPartiesInvitations = partiesInvitationsIn; Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size())); } else { e.printStackTrace(); } } });
这是我遇到的异常
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ com.parse.ParseException: java.lang.IllegalStateException: A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.Parse.run(Parse.java:971)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Handler.handleCallback(Handler.java:733)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:95)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.os.Looper.loop(Looper.java:212)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5135)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:877)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:693)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
02-11 13:06:03.907 28398-28398/com.whoCare.noOne W/System.err﹕ Caused by: java.lang.IllegalStateException: A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.createWithoutData(ParseObject.java:257)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.fromJSON(ParseObject.java:524)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseObject.fromJSON(ParseObject.java:499)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.convertFindResponse(ParseQuery.java:386)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.access0(ParseQuery.java:80)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.then(ParseQuery.java:567)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at com.parse.ParseQuery.then(ParseQuery.java:558)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at bolts.Task.run(Task.java:444)
02-11 13:06:03.917 28398-28398/com.whoCare.noOne W/System.err﹕ at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
我尝试将查询从 "whereContainsAll" 更改为 "whereContainedIn",但我一直收到相同的异常。我的代码有什么问题吗!?
改变这个
query.whereContainsAll("PartyId", partiesId);
query.findInBackground(new FindCallback<ParseObject>() {
public void done(List<ParseObject> partiesInvitationsIn, ParseException e) {
Log.d("UU-UPIL", "finding parties invitations");
if (e == null) {
for (int i = 0; i < partiesInvitationsIn.size(); i++) {
Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId());
}
mPartiesInvitations = partiesInvitationsIn;
Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size()));
} else {
e.printStackTrace();
}
}
});
对此
query.whereContainsAll("PartyId", partiesId);
query.findInBackground(new FindCallback<ParseObject>() {
@Override
public void done(List<ParseObject> partiesInvitationsIn, ParseException e) {
Log.d("UU-UPIL", "finding parties invitations");
if (e == null) {
for (int i = 0; i < partiesInvitationsIn.size(); i++) {
Log.v("UU-UPIL", partiesInvitationsIn.get(i).getObjectId());
}
mPartiesInvitations = partiesInvitationsIn;
Log.d("UU-UPIL", String.valueOf(partiesInvitationsIn.size()));
} else {
e.printStackTrace();
}
}
});
基本上就是在done方法前加一个@Override
A ParseObject subclass default constructor must not make changes to the object that cause it to be dirty.
我不确定您的代码中是否有一个来自 parseObject 的子类用于将数据库条目放入其中,但是当您修改该子类的构造函数中的项目时会引发此异常
Ensure that your subclass has a public default (i.e. zero-argument) constructor. You must not modify any ParseObject fields in this constructor.