I'm facing an issue with Room on Android.
I have a DAO with multiple methods
@Insert(onConflict = OnConflictStrategy.ABORT)
suspend fun insertEntity(entity: Entity)
@Update(onConflict = OnConflictStrategy.REPLACE)
suspend fun updateEntity(entity: Entity)
@Transaction
suspend fun insertOrUpdateEntities(entities: List<Entity>) {
entities.forEach { entity ->
try {
insertEntity(entity)
} catch (sqlException: SQLiteConstraintException) {
updateEntity(entity)
}
}
(I simplify the catch part, I change the object entity to do some merge of fields)
But, while the entity object in "updateEntity" is correct, the database is not update with the new values.
Do you have an idea why?
Thanks!