加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 如何查询在Parse中设置为指向其他表的指针的列的值

发布时间:2020-12-14 05:03:53 所属栏目:Java 来源:网络整理
导读:我使用 Parse作为我的应用程序我想查询一个表,其中列被设置为指向其他表的指针.这是查询: ParseQuery query = new ParseQuery("CategoryAttribute"); query.whereEqualTo("categoryId",categoryId); query.findInBackground(new FindCallback() { @Override
我使用 Parse作为我的应用程序我想查询一个表,其中列被设置为指向其他表的指针.这是查询:
ParseQuery query = new ParseQuery("CategoryAttribute");
        query.whereEqualTo("categoryId",categoryId);
        query.findInBackground(new FindCallback() {
            @Override
            public void done(List<ParSEObject> categoryAttributes,ParseException e) {
                if (e == null) {
                    for (int i = 0; i < categoryAttributes.size(); i++){
                        String atributeCategoryId = categoryAttributes.get(i).getString("categoryId");
                        String attributeKey  = categoryAttributes.get(i).getString("attributeKey");
                        String attributeValue   = categoryAttributes.get(i).getString("attributeValue");

                        setCategoryAtributeRow(atributeCategoryId,attributeKey,attributeValue);
                    }
                } else {
                    Log.d("score","Error: " + e.getMessage());
                }
            }
        });

所以categoryId列是指向其他表的指针.其他列工作正常.
我试图扫描API和指南,但找不到需要的解决方案.帮助将不胜感激!

解决方法

这是解决这个问题的方法:
首先,您需要从表的类型创建一个ParSEObject:
ParSEObject sale = ParSEObject.createParSEObject("Sale");

那么您需要从结果中获取ParSEObject:

sale = result.getParSEObject(pointer_field);

现在你可以从销售任何一个领域,就像你通常会做的一样,例如:

sale.getString("some_field")

注意:
当您进行查询时,如果希望在返回查询后能够从中提取数据,则必须包含指针字段.结果:

query.include("pointer_filed")

希望它有帮助

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读