房间:使用@Transaction时收到错误
我有一个方法在我的DAO类中使用@Transaction注释,这是导致以下错误:
DAO方法只能用以下其中一种进行注释:插入,删除,查询,更新
这是我的班级:
@Dao interface Dao { @Insert(onConflict = REPLACE) fun insertList(chacaras: List<String>) @Query("SELECT * FROM chacara WHERE cityId = :cityId") fun getListOfCity(cityId: String): LiveData<List<String>> @Delete fun deleteList(chacaraList: List<String>) @Transaction fun updateList(list: List<String>){ deleteList(list) insertList(list) } }
当我删除用@Transaction注解的方法时,它正常编译。 有没有什么办法解决这一问题?
- 在Android Studio中将Java文件传输到Kotlin中
- Kotlin android扩展,软件包不能被导入
- Kotlin – 运算符'=='不能应用于'可编辑'! 和'String'比较字符串
- 未解决的参考:数据绑定
- Android指挥:如何保留定位变化的观点
根据交易文件
将抽象Dao类中的方法标记为事务方法。
改变你的课程:
@Dao abstract class Dao { @Insert(onConflict = REPLACE) abstract fun insertList(chacaras: List<String>) @Query("SELECT * FROM chacara WHERE cityId = :cityId") fun abstract getListOfCity(cityId: String): LiveData<List<String>> @Delete abstract fun deleteList(chacaraList: List<String>) @Transaction open fun updateList(list: List<String>){ deleteList(list) insertList(list) } }
- 如何找到时间是今天或昨天在android
- 错误:com.app.android.dagger.component.AppComponent(unscoped)可能不引用作用域绑定:
- 直接解析配置“debugCompile”是不允许的
- 如何使用drawLine()绘制线条
- Android Kotlin计算速度(时间)
- 不能解决“内容长度和流长不一致”的错误
- Android Studio更新到0.6后,Kotlin问题
- Android:Kotlin:自定义webView – 不能作为函数调用。 找不到函数“invoke()”
- 在Android的Fragment.newInstance()模式中使用Kotlin的@JvmOverloads