I came across a Room tutorial that makes use of the @PrimaryKey
annotation on the class definition:
@Entity(foreignKeys = @ForeignKey(entity = User.class,
parentColumns = "id",
childColumns = "userId",
onDelete = CASCADE))
public class Repo {
...
}
Now, I have the following data class that want to use a primary key on:
@Parcel(Parcel.Serialization.BEAN)
data class Foo @ParcelConstructor constructor(var stringOne: String,
var stringTwo: String,
var stringThree: String): BaseFoo() {
...
}
So, I just added the @Entity(tableName = "Foo", foreignKeys = @ForeignKey(entity = Bar::class, parentColumns = "someCol", childColumns = "someOtherCol", onDelete = CASCADE))
snippet on the top as well, but I can't compile:
An annotation can't be used as the annotations argument.
I wonder: how come (what I think is) the same concept working in Java but not in Kotlin? Also, is there a way to go around this?
All input is welcome.