当前位置:网站首页>Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
2022-07-02 06:22:00 【原小明】
问题:
kotlin 更新值 1.2.6 版本时,room 表的实体类就编译不通过了,比如:
@Entity(tableName = "table_hex")
data class HexData constructor( @ColumnInfo(name = "id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0,
@ColumnInfo(name = "code")
var code: String = "",
@ColumnInfo(name = "datas")
var datas: String = "") {
constructor() : this(0)
}会出现下面警告和异常
Warning:(11, 2) 警告: There are multiple good constructors and Room will pick the no-arg construct当新增加的字段时,就会编译失败,找不到 setter 方法,其实都是上面警告引起的
解决:
在构造函数上添加 Ignore 注解即可
@Entity(tableName = "table_hex")
data class HexData constructor( @ColumnInfo(name = "id")
@PrimaryKey(autoGenerate = true)
var id: Int = 0,
@ColumnInfo(name = "code")
var code: String = "",
@ColumnInfo(name = "datas")
var datas: String = "") {
@Ignore
constructor() : this(0)
}边栏推荐
- Sentinel规则持久化到Nacos
- Is there a really free applet?
- TensorRT中的循环
- LeetCode 83. 删除排序链表中的重复元素
- WLAN相关知识点总结
- Arduino Wire 库使用
- Contest3147 - game 38 of 2021 Freshmen's personal training match_ E: Listen to songs and know music
- Three suggestions for all students who have graduated and will graduate
- 深入学习JVM底层(四):类文件结构
- Redis——热点key问题
猜你喜欢

Data playback partner rviz+plotjuggler

Redis——Cluster数据分布算法&哈希槽

Decryption skills of encrypted compressed files

递归(迷宫问题、8皇后问题)

Redis - hot key issues

Contest3145 - the 37th game of 2021 freshman individual training match_ H: Eat fish

Web components series (VIII) -- custom component style settings

Linear DP (split)

Lucene Basics

In depth understanding of JUC concurrency (II) concurrency theory
随机推荐
The Chinese word segmentation task is realized by using traditional methods (n-gram, HMM, etc.), neural network methods (CNN, LSTM, etc.) and pre training methods (Bert, etc.)
Contest3147 - game 38 of 2021 Freshmen's personal training match_ G: Flower bed
The intern left a big hole when he ran away and made two online problems, which made me miserable
Does the assignment of Boolean types such as tag attribute disabled selected checked not take effect?
构建学习tensorflow
ROS create workspace
Redis - hot key issues
广告业务Bug复盘总结
LeetCode 83. 删除排序链表中的重复元素
BGP 路由優選規則和通告原則
Contest3147 - game 38 of 2021 Freshmen's personal training match_ F: Polyhedral dice
深入学习JVM底层(四):类文件结构
BGP报文详细解释
找到页面当前元素z-index最高的数值
Sublime Text 配置php编译环境
数据科学【九】:SVD(二)
【每日一题】写一个函数,判断一个字符串是否为另外一个字符串旋转之后的字符串。
深入了解JUC并发(一)什么是JUC
LeetCode 283. Move zero
Redis - grande question clé