oneToMany方法无法在dbflow中关联外键

时间:2019-05-29 08:01:20

标签: android kotlin one-to-many dbflow

DBFlow版本为5.0.0-alpha1

我有两个关系模型(Zone,Content),一个区域关系mut内容,我在Content中设置了ForeignKey

    @Column
    @ForeignKey(
        stubbedRelationship = true,
        onDelete = ForeignKeyAction.CASCADE,
        references = arrayOf(
            ForeignKeyReference(
                columnName = "pid",
                foreignKeyColumnName = "zoneName"
            )
        )
    )
    var zone: Zone? = null

像这样在区域中一对多设置

@get:OneToMany(oneToManyMethods = arrayOf(OneToManyMethod.ALL))
    var records by oneToMany {
        select from Content::class where (Content_Table.pid.eq(zoneName))
    }

构建项目还可以,但是当我运行App和exec records方法,终端日志时会崩溃

Caused by: android.database.sqlite.SQLiteException: no such column: pid (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM `Content` WHERE `pid`=''

我仍然尝试这种方式

@ForeignKey(
        stubbedRelationship = true)
var zone: Zone? = null

但键zone_zoneName中存在相同的错误

0 个答案:

没有答案