【问题标题】:Loopback android sdk fields are nullLoopback android sdk 字段为空
【发布时间】:2016-03-31 05:32:02
【问题描述】:

我有从带有注释 ORMLite 的 Model 扩展而来的类 Item

@DatabaseTable
public class Item extends Model {
    @DatabaseField(id = true)
    public String id;

    @DatabaseField
    public String title;

    @DatabaseField
    public String details;

    @DatabaseField
    public String phone;

    @DatabaseField(defaultValue = "1000")
    public int position;

}
 ItemRepository repository = App.getRestAdapter().createRepository(ItemRepository.class);
        repository.findAll(new ListCallback<Item>() {
            @Override
            public void onSuccess(List<Item> objects) {
                //here is my breakpoint
             }
}

存储库

public class ItemRepository extends ModelRepository<Item> {
    public ItemRepository() {
        super("item", Item.class);
    }
}

/common/models/item.json 是:

{
  "name": "item",
  "base": "PersistedModel",
  "strict": false,
  "idInjection": false,
  "options": {
    "validateUpsert": true
  },
  "properties": {
    "details": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "phone": {
      "type": "string",
      "id": false
    },
    "id": {
      "type": "number",
      "id": true
    }
  },
  "validations": [],
  "relations": {},
  "acls": [],
  "methods": {}
}

问题是当我使用findAll 检索所有数据时,我得到了空字段对象的列表。屏幕数据存在,但它们不在字段中

【问题讨论】:

  • 提一下“@DatabaseTable”的来源会很有用。你在使用某种 ORM 吗?另外,请显示更多代码,尤其是您的所有 findAll 调用。
  • @barq 我更新了我的问题
  • 我也试过没有 ORMLite 注释,没有帮助

标签: android loopbackjs strongloop


【解决方案1】:

终于找到答案了。当我添加 setter 和 getter 时,它起作用了!

【讨论】:

    猜你喜欢
    • 2016-10-13
    • 2016-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-08
    相关资源
    最近更新 更多