当前位置:网站首页>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)
}边栏推荐
- VLAN experiment of switching technology
- 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.)
- It is said that Kwai will pay for the Tiktok super fast version of the video? How can you miss this opportunity to collect wool?
- LeetCode 77. 组合
- Distributed transactions: the final consistency scheme of reliable messages
- Redis - grande question clé
- Use of Arduino wire Library
- Is there a really free applet?
- Eco express micro engine system has supported one click deployment to cloud hosting
- Code skills - Controller Parameter annotation @requestparam
猜你喜欢

Cglib代理-代码增强测试

Don't use the new WP collection. Don't use WordPress collection without update

Common means of modeling: combination

Sparse array (nonlinear structure)

锐捷EBGP 配置案例

VRRP之监视上行链路

Hydration failed because the initial UI does not match what was rendered on the server. One of the reasons for the problem

Distributed transactions: the final consistency scheme of reliable messages

Eco express micro engine system has supported one click deployment to cloud hosting

WLAN相关知识点总结
随机推荐
一起学习SQL中各种join以及它们的区别
Data playback partner rviz+plotjuggler
TensorRT的命令行程序
介绍两款代码自动生成器,帮助提升工作效率
标签属性disabled selected checked等布尔类型赋值不生效?
ModuleNotFoundError: No module named ‘jieba.analyse‘; ‘jieba‘ is not a package
实习生跑路留了一个大坑,搞出2个线上问题,我被坑惨了
Redis——大Key问题
Eco express micro engine system has supported one click deployment to cloud hosting
Cglib代理-代码增强测试
LeetCode 77. 组合
Contest3147 - game 38 of 2021 Freshmen's personal training match_ 1: Maximum palindromes
稀疏数组(非线性结构)
Lucene Basics
LeetCode 27. 移除元素
注解和反射详解以及运用
MySQL的10大經典錯誤
In depth understanding of JUC concurrency (I) what is JUC
Linked list (linear structure)
数据科学【九】:SVD(二)