The error I am getting is:
error: theme_id, picture_id referenced in the primary key does not exists in the Entity. Available column names:theme_id, picture_id, image
I have looked extensively online but i cannot find anything about this. This error only seemst to pop uw when trying to use the composite key. If I annotate one of the fields with a normal PrimaryKey it works just fine. I do not understand what is going on here and it is frustrating that i cannot find anything online about this. I hope you guys will be able to help me.
Entity
@Entity(primaryKeys = {"theme_id, picture_id"}, tableName = "picture")
public class Picture {
@ColumnInfo(name = "theme_id")
private int themeId;
@ColumnInfo(name = "picture_id")
private int pictureId;
@ColumnInfo(name = "image", typeAffinity = ColumnInfo.BLOB)
private byte[] image;
}
Dao
@Dao
public interface PictureDao {
@Insert
void instertPictures(Picture... pictures);
@Update
void updatePictures(Picture... pictures);
@Delete
void deletePictures(Picture... pictures);
@Query("SELECT * FROM picture")
List<Picture> getAllPictures();
@Query("SELECT * FROM picture WHERE theme_id = :themeId")
List<Picture> getThemePictures(int themeId);
@Query("SELECT * FROM picture WHERE theme_id = :themeId AND picture_id = :pictureId")
Picture getPicture(int themeId, int pictureId);
}
Database
@Database(entities = {Picture.class}, version = 1, exportSchema = false)
public abstract class PictureDatabase extends RoomDatabase {
public static final String NAME = "picture_db";
public abstract PictureDao pictureDao();
}