解析查询失败:无法编码与未保存的ParseObject的关联

时间:2015-12-24 13:08:24

标签: java android parse-platform

我尝试查询以查找“Lutin”提供的“Enfants”。我得到了Lutin,我在“Enfant”上创建了一个查询

public class SeeEnfantForLutinActivity extends AppCompatActivity {

Lutin lutin;
String lutin_ID;
List<Enfant> list_enfants = new ArrayList<>();

ListView list;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_see_enfant_for_lutin);

    TextView label = (TextView) findViewById(R.id.label_enfant_lutin);
    Bundle bundle = getIntent().getExtras();
    lutin = bundle.getParcelable("LUTIN");
    lutin_ID = bundle.getString("LUTIN_ID");
    label.setText(getString(R.string.label_enfant_for_lutin, lutin.getName()));

    list = (ListView) findViewById(R.id.list_enfant_lutin);

    ParseQuery<Enfant> query = ParseQuery.getQuery("Enfant");
    query.whereEqualTo("Lutin",lutin);

    query.findInBackground(new FindCallback<Enfant>() {
        @Override
        public void done(List<Enfant> objects, ParseException e) {
            if (e == null) {

                for (Enfant en : objects) {
                    list_enfants.add(en);
                }

                ArrayAdapter<Enfant> enfantArrayAdapter =
                        new ArrayAdapter<Enfant>(SeeEnfantForLutinActivity.this, android.R.layout.simple_list_item_1, list_enfants);
                list.setAdapter(enfantArrayAdapter);
            } else {
                e.printStackTrace();
            }
        }
    });


}
}

但是在线:     query.findInBackground(new FindCallback(){

抛出异常:

  

com.parse.ParseException:java.lang.IllegalStateException:无法编码与未保存的ParseObject的关联

哪里有错误?我用原始对象(String,int,...)

成功完成了同样的事情

1 个答案:

答案 0 :(得分:0)

试试这个

ParseQuery<ParseObject> query = ParseQuery.getQuery("yourTable");
    query.whereEqualTo("Lutin",lutin);
query.findInBackground(new FindCallback<ParseObject>() {
        @Override
        public void done(List<ParseObject> parseObjects, ParseException e) {
            if (e == null) {
                      //do your work
            }else{

            }
        }
       });