[英]error: Cannot find setter for field - Room
I don't really know why I have this error.我真的不知道为什么我有这个错误。 The code seems pretty straight forward.代码看起来很简单。
@Entity(indices = {@Index("clientLocalId")})
.
.
private @PrimaryKey String clientLocalId;
public String getClientLocalId() {
return clientLocalId;
}
public void setClientLocalId(long idInvoice, String receipt) {
this.clientLocalId = String.valueOf(idInvoice) + " " + receipt;
}
I tried to changed the name in just client , restarted and cleared caches, same error.我试图在client中更改名称,重新启动并清除缓存,同样的错误。
error: Cannot find setter for field.错误:找不到字段的设置器。 private @PrimaryKey String clientLocalId;私人@PrimaryKey String clientLocalId; ^ ^
Any idea is appreciated.任何想法表示赞赏。 Thanks in advance !提前致谢 !
it happened because of the second Parameter receipt
of clientLocalId
, remove it or add another setter method, i recommend you add receipt to your clientLocalId
out of entity class before inserting in Database这是因为clientLocalId
的第二个参数receipt
,删除它或添加另一个 setter 方法,我建议您在插入数据库之前从实体 class 将接收添加到您的clientLocalId
Room is looking for a setter that just takes a single String value. Room 正在寻找一个只接受单个字符串值的设置器。 Your method has two.你的方法有两个。
Change it to the below and use another method to create your concatenated id.将其更改为以下内容并使用另一种方法来创建您的串联 id。
public void setClientLocalId(String id) {
this.clientLocalId = id;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.