Room 6 min read

Room 3.1 Alpha: Per-DAO Return Type Converters, Prepared Statement Cache and allowDataLossOnRecovery

Room 3.0 went stable on July 1, 2026, and the androidx.room3 3.1 alpha line has been quietly adding the knobs people asked for since. The latest, 3.1.0-alpha04 (Nov 18, 2026), is the fourth alpha; the stable line is currently 3.0.3. This post walks through what 3.1 adds so far, with the API names taken from the official release notes, and what I would and would not try in a production app today.

3.1.0-alpha04
latest alpha, Nov 18, 2026
3.0.3
current stable release
Kotlin 2.2
required by 3.1 libraries since alpha03

1. Property-centric entities (alpha01)

The annotations @ColumnInfo, @PrimaryKey, @Relation, @Embedded, @Ignore and @ColumnTypeConverters now accept AnnotationTarget.PROPERTY. Room becomes property-centric rather than field-centric, so a property without a backing field can represent a column or a query result column. It still needs a usable getter and either a usable setter or a place in the primary constructor.

2. Connection and statement tuning

import androidx.room3.Room
import kotlin.time.Duration.Companion.seconds

val db = Room.databaseBuilder<MusicDatabase>(context, "music.db")
    .setDriver(AndroidSQLiteDriver())
    .setConnectionPoolTimeout(10.seconds)
    .setPreparedStatementCacheSize(32)
    .allowDataLossOnRecovery()
    .build()

Note the name: allowDataLossOnRecovery() is an explicit opt-in. For a cache database it is a sensible safety net; for a database holding user-authored data, I would rather surface the failure and restore from backup than silently start empty. The cache size value above is an arbitrary example, not a recommendation from the release notes.

3. Built-in Uuid support (alpha01)

Room now has a built-in column type converter for kotlin.uuid.Uuid, and the generated _Impl classes suppress OPT_IN_USAGE_ERROR and OPT_IN_USAGE. That means DAOs and entities can use @RequiresOptIn types like Uuid without adding -opt-in to freeCompilerArgs.

4. DAO return type converters get finer-grained (alpha04)

In Room 3.0, custom return types such as PagingSource are produced by @DaoReturnTypeConverter functions registered through @DaoReturnTypeConverters. Alpha04 makes the registration more flexible:

@Dao
interface MusicDao {
    @Query("SELECT * FROM Song")
    @DaoReturnTypeConverters(PagingSourceDaoReturnTypeConverter::class)
    fun pagedSongs(): PagingSource<Int, Song>

    @Query("SELECT * FROM Song WHERE artistId = :artistId")
    suspend fun songsBy(artistId: Long): List<Song>
}

The practical win is blast radius: you can scope an exotic converter to the one function that needs it instead of registering it for a whole database. Placing the annotation on a function is what alpha04 documents; the exact placement in my snippet follows that description and I have not compiled it against the alpha.

5. Fixes worth knowing about

6. What I would do

If you are on Room 2.x, the move to androidx.room3 is still the big decision, and 3.0.3 is the version to evaluate. Stay off the 3.1 alphas in production, but try them in a branch if you hit one of the fixed issues above, mainly the KSP default-value schema bug or the transaction cancellation behavior. Remember 3.1 libraries target Kotlin 2.2 and require kotlinc 2.2.

Takeaway: Room 3.1 is about control and correctness: finer-scoped DAO converters, tunable connection and statement caches, an explicit recovery opt-in, and a set of KSP and transaction fixes. Evaluate on 3.0.3, track the alphas for the fixes you need.

Sources: AndroidX Room 3.0 release notes on developer.android.com (3.0.0 through 3.1.0-alpha04), and the AndroidX library release index, both fetched Nov 22, 2026. Code samples are my own illustrations of the documented APIs and were not compiled against the alpha.

Comments 0

No comments yet. Be the first to leave one!

Leave a comment