I have a table with two foreign key into two different tables
This is my table :
@Entity(
tableName = Constants.TABLE_NAME_PICTURE,
foreignKeys = {
@ForeignKey(
entity = BIN.class,
parentColumns = "id",
childColumns = "bin_id"
),
@ForeignKey(
entity = ORDER.class,
parentColumns = "id",
childColumns = "order_id"
)},
indices = {@Index("id"), @Index(value = {"bin_id","order_id"})})
public class PICTURE {
@PrimaryKey(autoGenerate = true)
@ColumnInfo(name = "id")
public long id;
@Attribute(name = "name", required = false)
@ColumnInfo(name = "name")
public String name;
@ColumnInfo(name = "bin_id")
public int binId;
@ColumnInfo(name = "order_id")
public int orderId;
and when I insert a PICTURE to the database I get :
android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787)