【发布时间】:2017-11-03 09:22:39
【问题描述】:
实际上,我很清楚如何将内部 jsonArray 与 Room 持久性库一起使用。 POJO类如下:
@Entity(tableName = "customer")
public class CustomerResponseModel {
@PrimaryKey
@ColumnInfo(name = "version")
@SerializedName("version")
private int version;
@ColumnInfo(name = "sync_date")
@SerializedName("sync_date")
private long syncDate;
@Relation(parentColumn = "version", entityColumn = "customerId", entity = CustomerList.class)
private List<CustomerList> customerList;
}
@Entity
public class CustomerList {
@PrimaryKey
@SerializedName("customer_id")
private String customerId;
@SerializedName("customer_type")
private String customerType;
@SerializedName("customer_name")
private String customerName;
@SerializedName("customer_addresses")
@Relation(parentColumn = "customerId", entityColumn = "id", entity = CustomerAddress.class)
private List<CustomerAddress> customerAddresses;
}
@Entity
public class CustomerAddress {
@PrimaryKey(autoGenerate = true)
private int id;
@SerializedName("address")
private String address;
@SerializedName("contact")
private String contact;
}
Error:(15, 8) 错误:实体不能有关系。
【问题讨论】:
-
那么预期的行为是什么?
-
您应该在问题中添加您可以提供的任何其他信息。
标签: android-room