android - FOREIGN KEY 约束失败(代码 787 SQLITE_CONSTRAINT_FOREIGNKEY)
问题描述
我不知道为什么在调用createBrowseRecord()
函数时会出现此错误。我的代码如下,任何想法都将不胜感激。
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun createBrowseRecord(br:BrowseRecord)
@Entity(foreignKeys = [ForeignKey(entity = Composition::class,parentColumns =["id"],childColumns = ["compositionId"] ,onDelete = ForeignKey.CASCADE)])
data class BrowseRecord(@PrimaryKey val compositionId:String, val browseTime:Long)
@Entity
data class Composition(
val author: String,
val commentAmount: Int,
var cover: String,
val description: String,
val downloadURL: String,
val backGround:String,
val duration: String,
@PrimaryKey val id: String,
var isLike: Boolean,
val likeAmount: Int,
val title: String
)
解决方案
推荐阅读
- php - 显示页脚的简码
- netbeans - 哪一个是 NetBeans 中的“选择”键?
- angular - 使用带有 aot 的 file:// 在新窗口上进行深度链接
- android - 在 AutoCompleteTextView 中进行选择时崩溃
- python - 根据其他列更新列值
- google-maps - 谷歌地图 JavaScript 街景错误
- scala - Scala Anorm 查询异常处理
- angular - Leaflet MarkerCluster removeOutsideVisibleBounds 不起作用
- c# - C# WPF - 类的数据绑定 ObservableCollection 的组合框
- python - 程序没有在python中打印结果就符合要求