在Android房间持久化库中如何将整个Model对象插入到本身具有另一个列表的表中.
让我告诉你我的意思:
@Entity(tableName = TABLE_NAME)
public class CountryModel {
public static final String TABLE_NAME = "Countries";
@PrimaryKey
private int idCountry;
private List<CountryLang> countryLang = null;
public int getIdCountry() {
return idCountry;
}
public void setIdCountry(int idCountry) {
this.idCountry = idCountry;
}
public String getIsoCode() {
return isoCode;
}
public void setIsoCode(String isoCode) {
this.isoCode = isoCode;
}
/**
here i am providing a list of coutry information how to insert
this into db along with CountryModel at same …
Run Code Online (Sandbox Code Playgroud) 我试图通过Room Persistence库将数据库添加到我的Android应用程序中.我正确地遵循了说明,但在编译时得到了上述错误.另外Room无法找到我的getter,虽然我可以在我的代码中清楚地看到所有这些.任何帮助将非常感激.提前致谢.
这是我的实体代码:
@Entity(tableName = "users", indices = @Index(value = "username", unique = true))
public class User {
@NonNull
public String getuId() {
return uId;
}
public void setuId(@NonNull String uId) {
this.uId = uId;
}
public String getuUsername() {
return uUsername;
}
public void setuUsername(String uUsername) {
this.uUsername = uUsername;
}
@NonNull
public String getuPassword() {
return uPassword;
}
public void setuPassword(@NonNull String uPassword) {
this.uPassword = uPassword;
}
public String getuEmail() {
return uEmail;
}
public void setuEmail(String …
Run Code Online (Sandbox Code Playgroud) 我有一个数据类,我Entity
从它为我的数据库创建了一个。
这是我的数据类:
@Entity
@Parcelize
data class Tapligh(
@PrimaryKey(autoGenerate = true)
var id: Long,
@SerializedName("title") var title: String?,
@SerializedName("type") var type: Int?,
@SerializedName("os") var os: Int?,
@SerializedName("logo") var logo: String?,
@SerializedName("template") var template: String?,
@SerializedName("action") var action: String?,
@SerializedName("date") var date: String?,
@Embedded
@SerializedName("videos") var videos: Videos?,
) : Parcelable {
fun getTaplighType(): Int {
return when (this.type) {
0 -> TaplighType.IMAGE.type
1 -> TaplighType.VIDEO.type
else -> TaplighType.NATIVE.type
}
}
}
@Parcelize
data class Videos(
@SerializedName("land") var land: String?, …
Run Code Online (Sandbox Code Playgroud)