https://kotlinlang.org logo
#room
Title
# room
a

Abhimanyu

11/18/2023, 7:30 AM
Hi all, What is the use-case for
OnConflictStrategy.ABORT
or
OnConflictStrategy.IGNORE
specifically for
@Update
? My understanding is for
@Insert
, if there is an existing data matching the given primary key, it creates a conflict and we can resolve using
Copy code
ABORT - to abort the transaction. The transaction is rolled back.
IGNORE - An Insert DAO method that returns the inserted rows ids will return -1 for rows that are not inserted since this strategy will ignore the row if there is a conflict.
REPLACE - An Insert DAO method that returns the inserted rows ids will never return -1 since this strategy will always insert a row even if there is a conflict.
But, since
@Update
is used to modify existing data, what is the use-case for
OnConflictStrategy.ABORT
or
OnConflictStrategy.IGNORE
?
OnConflictStrategy.REPLACE
will allow us to update the data as I expect.