Page 1 of 1

What happens when you create a DAO method and annotate it with @Insert? Example: @Dao interface MyDao { @Insert(onConfli

Posted: Mon Aug 01, 2022 9:41 am
by answerhappygod
What happens when you create a DAO method and annotate it with @Insert?
Example:
@Dao
interface MyDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertUsers(vararg users: User)
}

A. Room generates an implementation that inserts all parameters into the database in a single transaction.
B. Room modifies a set of entities, given as parameters, in the database. It uses a query that matches against the primary key of each entity.
C. Room removes a set of entities, given as parameters, from the database. It uses the primary keys to find the entities to delete.