【发布时间】:2019-11-11 06:54:51
【问题描述】:
请不要将此标记为重复我看过其他类似的帖子,但没有任何帮助
我的实体:
@Entity(tableName = "batch_table")
data class Batch(
val batch_id: String? ="",
val batch_name: String? ="",
val user_m_id: String? ="",
val user_profile_id: String? =""
){
@PrimaryKey(autoGenerate = true)
var id1: Int? = 0
constructor():this("","","","")
}
我的道:
@Dao
interface BatchDao{
@Insert
suspend fun insert(batch : MutableList<Batch>)
@Query("delete from batch_table")
suspend fun deleteBatchTable()
@Query(" select * from batch_table ")
suspend fun getAllBatches() :List<Batch>
@Query("select batch_name from batch_table where batch_id = :batch_id")
suspend fun getBatchName(batch_id:String)
@Transaction
suspend fun insertBatches(batch: MutableList<Batch>){
deleteBatchTable()
insert(batch)
}
我使用的是room,我所做的只是在我的dao 中添加第四个函数(getBatchName),但我不确定为什么会开始出现此错误。
编译时的错误:
error: 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). - `kotlin.Unit`
【问题讨论】:
标签: android kotlin android-room