当前位置: 代码迷 >> 综合 >> 错误: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a
  详细解决方案

错误: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a

热度:27   发布时间:2023-10-19 06:34:02.0

完整错误: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).

百度翻译:

错误:实体和POJO必须具有可用的公共构造函数。可以有一个空构造函数或一个其参数与字段匹配的构造函数(按名称和类型)。

意思是说必须构造一个函数,中文网文档也没有说明要构造一个函数,不知道是不是没有找到。

解决:

Kotlin:实体和Pojos必须有一个可用的公共构造函数

@Entity(tableName = "wan_bean")
data class WanBean (@Ignore val children: List<Any>?,@ColumnInfo(name = "courseId_") var courseId: Int?,@field:PrimaryKey(autoGenerate = true) var id: Int?,@ColumnInfo(name = "name_") var name: String?,@ColumnInfo(name = "order_") var order: Int?,@ColumnInfo(name = "parentChapterId_") var parentChapterId: Int?,@ColumnInfo(name = "userControlSetTop_") var userControlSetTop: Boolean?,@ColumnInfo(name = "visible_") var visible: Int?
){constructor() : this(null,UNKNOWN,UNKNOWN,"", UNKNOWN,UNKNOWN,false,UNKNOWN)}

应该可以解决了!!!

  相关解决方案