I have a sqlite database and i want to change my database to Room database
.
One of tables has no any primary key and just have two foreign key.
I created the table before room with this query:
CREATE TABLE student_performance(
class_id int ,
student_id char(10),
class_date date ,
absent boolean DEFAULT 0,
delay boolean DEFAULT 0,
positive int DEFAULT 0,
negative int DEFAULT 0,
quiz float ,
FOREIGN KEY (student_id , class_id) REFERENCES student(student_id , class_id)
ON DELETE CASCADE
ON UPDATE CASCADE);
Now i define table for room:
@Entity(tableName = "performance",
foreignKeys = {@ForeignKey(
entity = StudentEntry.class,
parentColumns = {CLASS_ID, STUDENT_ID},
childColumns = {CLASS_ID, STUDENT_ID},
onDelete = CASCADE, onUpdate = CASCADE)})
public class PerformanceEntry {
.
.
.
}
But it gives error :
error: An entity must have at least 1 field annotated with @PrimaryKey
I dont know how can define this table for room database.