I'm using a Room Sqlite database on Android. I have the following database entities:
@Entity
public static class TopEntry {
@Ignore
public DatabaseDAOs.BaseDAO dao;
}
@Entity
public static class DatabaseEntry extends TopEntry {
@PrimaryKey(autoGenerate = true)
public long id;
@PrimaryKey
public long sessionID;
public Long eventNanoTime;
public Long milliTimestamp;
}
As you can see, I would like to have a composite primary key. One primary key should be auto-incremented.
This is not possible and throws an error:
You cannot have multiple primary keys defined in an Entity. If you want to declare a composite primary key, you should use @Entity#primaryKeys and not use @PrimaryKey
How can I implement this in Room?