【发布时间】:2018-05-18 20:29:03
【问题描述】:
我在我的 java 后端服务器中使用 uuid。所以我需要在房间 android 中使用该 uuid 来确保实体正确同步。 我知道Is it possible to apply primary key on the text fields in android database 和text as primarykey in android。我想创造这样的东西
@Entity(tableName = CrewColumns.TABLE_NAME)
@TypeConverters(BigDecimalConverter::class)
@JsonIgnoreProperties(ignoreUnknown = true)
class Crew() {
constructor (uuid: String) : this() {
this.uuid = uuid;
}
/**
* The unique ID of the item.
*/
@PrimaryKey
@ColumnInfo(name = CrewColumns.UUID)
var uuid: String = ""
@ColumnInfo(name = CrewColumns.NAME)
var name: String = ""
}
Room(DAO 等)会有问题吗?谢谢。
【问题讨论】:
-
您当然可以使用字符串作为主键。您在尝试时遇到了什么具体问题?
-
@CommonsWare 目前没有。
标签: java android kotlin android-room