当前位置:网站首页>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)
}边栏推荐
- The difference between session and cookies
- CUDA中的异步数据拷贝
- kali最新更新指南
- 利用传统方法(N-gram,HMM等)、神经网络方法(CNN,LSTM等)和预训练方法(Bert等)的中文分词任务实现
- 深入学习JVM底层(二):HotSpot虚拟机对象
- 递归(迷宫问题、8皇后问题)
- Current situation analysis of Devops and noops
- MySQL的10大經典錯誤
- Idea announced a new default UI, which is too refreshing (including the application link)
- CUDA与Direct3D 一致性
猜你喜欢

Redis——大Key問題

Idea announced a new default UI, which is too refreshing (including the application link)

Ruijie ebgp configuration case

Sentinel规则持久化到Nacos

Contest3147 - game 38 of 2021 Freshmen's personal training match_ A: chicken

Learn about various joins in SQL and their differences

日期时间API详解

BGP中的状态机

Sentinel 阿里开源流量防护组件

链表(线性结构)
随机推荐
Redis——大Key問題
华为MindSpore开源实习机试题
阿里云MFA绑定Chrome浏览器
LeetCode 39. 组合总和
找到页面当前元素z-index最高的数值
LeetCode 283. Move zero
递归(迷宫问题、8皇后问题)
eslint配置代码自动格式化
Lucene Basics
TensorRT中的循环
Data science [viii]: SVD (I)
标签属性disabled selected checked等布尔类型赋值不生效?
VLAN experiment of switching technology
CUDA中的Warp matrix functions
Decryption skills of encrypted compressed files
Is there a really free applet?
Cglib agent - Code enhancement test
数据科学【八】:SVD(一)
Eco express micro engine system has supported one click deployment to cloud hosting
广告业务Bug复盘总结