Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Version used: 2.1.0-alpha04
Devices/Android versions reproduced on: Pixel 2 XL, Android Pie
Refer to the project at
@Entity
data class Info ( @PrimaryKey val name : String )
@Dao
abstract class InfoDao {
@Insert
abstract suspend fun insert( info : Info )
@Query( "DELETE FROM Info" )
abstract suspend fun deleteAll()
@Transaction
open suspend fun deleteAllAndInsert( info : Info ) {
deleteAll()
insert( info )
}
}
Compilation fails with this even though deleteAllAndInsert returns Unit
Method annotated with @Transaction must not return deferred/async return type androidx.lifecycle.LiveData. Since transactions are thread confined and Room cannot guarantee that all queries in the method implementation are performed on the same thread, only synchronous @Transaction implemented methods are allowed. If a transaction is started and a change of thread is done and waited upon then a database deadlock can occur if the additional thread attempts to perform a query. This restrictions prevents such situation from occurring.