Skip to content Skip to sidebar Skip to footer

Sqliteconstraintexception: How To Map "no Relationship" With A Foreign Key In Room

I am using the Android Room Persistence Library as ORM. I have the following Entity: @Entity(tableName = 'log_entries', foreignKeys = { @ForeignKey(

Solution 1:

You need to use Long as datatype and insert the entity with null as servingId.

// ...
LogEntry logEntry = new LogEntry();
logEntry.setServingId(null);
// ...

db.logEntryDao().add(logEntry);

Post a Comment for "Sqliteconstraintexception: How To Map "no Relationship" With A Foreign Key In Room"