赞
踩
Kotlin:实体和pojo必须有一个可用的公共构造函数。您可以有一个空的构造函数或一个其参数与字段(按名称和类型)匹配的构造函数。
@Entity(tableName = "inspectItem")
data class InspectItemInfo(
@PrimaryKey
@ColumnInfo(name = "id")
@NonNull
var carInspectRecordId: Int,
var cubeName: String,
@Ignore
var imageType: String,
var plateColor: String,
var plateNo: String,
var shotTime: String,
var storagePath: String,
var bottomImageUrl: String
)
报错信息: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).
说明:提供空构造方法。
@Entity(tableName = "inspectItem") data class InspectItemInfo( @PrimaryKey @ColumnInfo(name = "id") @NonNull var carInspectRecordId: Int, var cubeName: String, @Ignore var imageType: String, var plateColor: String, var plateNo: String, var shotTime: String, var storagePath: String, var bottomImageUrl: String ) { constructor() : this(0, "", "", "", "", "", "", "") }
说明:ignore的属性需要给默认值。
@Entity(tableName = "inspectItem") data class InspectItemInfo( @PrimaryKey @ColumnInfo(name = "id") @NonNull var carInspectRecordId: Int, var cubeName: String, var plateColor: String, var plateNo: String, var shotTime: String, var storagePath: String, var bottomImageUrl: String ) { @Ignore var imageType: String = "" }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。