Loopback android sdk字段为空

时间:2016-02-23 06:35:22

标签: android loopbackjs strongloop

我有类Item,它从带有注释ORMLite的模型扩展

@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重新获取所有数据时,我得到了空的对象列表。屏幕数据存在,但它们不在字段中

1 个答案:

答案 0 :(得分:0)

最后我找到了答案。当我添加setter和getter时,它有效!