'Room @ForeignKey This annotation is not applicable to target member property with backing field when updating to 2.4.0

I have an issue when updating to Room 2.4.0-rc01 on fields annotated with @ForeignKey. This version adds an empty @Target in its definition making it impossible to target properties.

@Entity
class Foo {
    @PrimaryKey
    @ColumnInfo
    var id: String = ""

    @ForeignKey(entity = Foo::class, parentColumns = ["bar_id"], childColumns = ["bar"])
    @ColumnInfo
    var bar: String? = null
}

@Entity
class Bar {
    @PrimaryKey
    @ColumnInfo
    var bar_id: String = ""
}

I have the following error at the @ForeignKey annotation: This annotation is not applicable to target 'member property with backing field'



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source