Room
Latest Update | Current Stable Release | Next Release Candidate | Beta Release | Alpha Release |
---|---|---|---|---|
December 16, 2020 | 2.2.6 | - | - | 2.3.0-alpha04 |
Declaring dependencies
To add a dependency on Room, you must add the Google Maven repository to your project. Read Google's Maven repository for more information.
Dependencies for Room include testing Room migrations and Room RxJava
Add the dependencies for the artifacts you need in the build.gradle
file for
your app or module:
Kotlin
dependencies { def room_version = "2.2.6" implementation "androidx.room:room-runtime:$room_version" kapt "androidx.room:room-compiler:$room_version" // optional - Kotlin Extensions and Coroutines support for Room implementation "androidx.room:room-ktx:$room_version" // optional - Test helpers testImplementation "androidx.room:room-testing:$room_version" }
Java
dependencies { def room_version = "2.2.6" implementation "androidx.room:room-runtime:$room_version" annotationProcessor "androidx.room:room-compiler:$room_version" // optional - RxJava support for Room implementation "androidx.room:room-rxjava2:$room_version" // optional - Guava support for Room, including Optional and ListenableFuture implementation "androidx.room:room-guava:$room_version" // optional - Test helpers testImplementation "androidx.room:room-testing:$room_version" }
For information on using Kotlin extensions, see the ktx documentation.
For more information about dependencies, see Add Build Dependencies.
Configuring Compiler Options
Room has the following annotation processor options:
room.schemaLocation
: Configures and enables exporting database schemas into JSON files in the given directory. See Room Migrations for more information.room.incremental
: Enables Gradle incremental annotation processor.room.expandProjection
: Configures Room to rewrite queries such that their top star projection is expanded to only contain the columns defined in the DAO method return type.
An example of how these options can be configured are shown in the following code snippet:
android { ... defaultConfig { ... javaCompileOptions { annotationProcessorOptions { arguments += [ "room.schemaLocation":"$projectDir/schemas".toString(), "room.incremental":"true", "room.expandProjection":"true"] } } } }
Feedback
Your feedback helps make Jetpack better. Let us know if you discover new issues or have ideas for improving this library. Please take a look at the existing issues in this library before you create a new one. You can add your vote to an existing issue by clicking the star button.
See the Issue Tracker documentation for more information.
Version 2.3.0
Version 2.3.0-alpha04
December 16, 2020
androidx.room:room-*:2.3.0-alpha04
is released. Version 2.3.0-alpha04 contains these commits.
New Features
- Room now offers a general callback API
RoomDatabase.QueryCallback
, for when queries are about to execute, which can be useful for logging in debug builds. The callback can be set viaRoomDatabase.Builder#setQueryCallback()
. (Iaa513, b/174478034, b/74877608) - Room will now default to using an Enum to String and vice versa type converter if none is provided. If a type converter for an enum already exists, Room will prioritize using it over the default one. (b/73132006)
Known Issue
- If a one-way type converter for reading already exists for the Enum, Room might accidentally use the built-in String to Enum converter which might not be desired. This is a known issue and can be fixed by making it a two-way converter. See: b/175707691
Bug Fixes
- Fixed an issue where Room would incorrectly disabled incremental annotation processing in newer JDK versions. (b/171387388)
- Fixed an issue with Room finding the generated class when multiple class loaders are used. Thanks for the fix ‘Serendipity | 892449346@qq.com’! (b/170141113)
- Fixed an issue where Room would generate incorrect code when a Kotlin
@Dao
had a base class whose generics are primitives in the JVM. (b/160258066)
External Contribution
- Room will now default to using
beginTransactionNonExclusive
if WAL mode is enabled and API is 16 or more. Thanks to ‘Ahmed I. Khalil | ahmedibrahimkhali@gmail.com’! (b/126258791)
Version 2.3.0-alpha03
October 14, 2020
androidx.room:room-*:2.3.0-alpha03
is released. Version 2.3.0-alpha03 contains these commits.
New Features
Room now has APIs for providing instances of type converters such that the app can control their initialization. To mark a type converter that will be provided to Room use the new annotation
@ProvidedTypeConverter
. Thanks to ‘mzgreen yairobbe@gmail.com’. (Ie4fa5, b/121067210)Room now has APIs for creating a database using a pre-packaged database read from an input stream. This allows for cases such as when the pre-package database is gzipped. Thanks to ‘Ahmed El-Helw ahmedre@gmail.com’ (3e6792, b/146911060)
API Changes
Added missing target to
@ForeignKey
annotation preventing its usage outside of the@Entity
annotation. (Iced1e)The field
mCallbacks
inRoomDatabase.java
is now hidden. (d576cb, b/76109329)
Bug Fixes
Update to TypeConverters documentation to clarify that TypeConverters can only be used to convert columns / fields and not rows. (I07c56, b/77307836)
Update to the DaoProcessor to fix compiler error on Dao with a generic super type with Kotlin "primitives". (Ice6bb, b/160258066)
Update add/remove observer methods documentation to clarify threading (Ifd1d9, b/153948821)
Fix an issue with Room incorrectly validating FTS tables that declared their rowid column. (d62ebc, b/145858914)
External Contributions
Fix upper/lowercase locale issues related to Turkish (5746e3), b/68159494
Replace the
ConcurrentHashMap
insideRoomDatabase
withCollections.synchronizedMap()
to avoid issues on Android Lollipop (d1cfc7, b/162431855)Add a onOpenPrepackagedDatabase callback for when a prepackaged DB is copied. (I1ba74, b/148934423)
Version 2.3.0-alpha02
July 22, 2020
androidx.room:room-*:2.3.0-alpha02
is released. Version 2.3.0-alpha02 contains these commits.
New Features
- RxJava3 Support: Room now supports RxJava3 types. Similar to RxJava2 you can declare DAO methods whose return type are Flowable, Single, Maybe and Completable. Additionally a new artifact
androidx.room:room-rxjava3
is available to support RxJava3. (b/152427884)
API Changes
- Declaring a
@TypeConverter
in Kotlin Object class is now supported. (b/151110764) - Room's incremental annotation processing option is now ON by default. (b/112110217)
Version 2.3.0-alpha01
June 10, 2020
androidx.room:room-*:2.3.0-alpha01
is released. Version 2.3.0-alpha01 contains these commits.
New Features
Paging 3.0 Support: Room will now support generating implementations for
@Query
annotated methods whose return type isandroidx.paging.PagingSource
.@Dao interface UserDao { @Query("SELECT * FROM users ORDER BY id ASC") fun pagingSource(): PagingSource<Int, User> }
API Changes
@RemoveUnusedColumns
is a new convenient annotation that makes Room rewrite the ‘*’ projection in a query such that unused columns in the result are removed.- The processor option
room.expandProjection
is now deprecated. Use@RemoveUnusedColumns
as a replacement for Room optimizing queries with star projections. Note that@RemoveUnusedColumn
does not replace the column conflict solutionroom.expandProjection
offered with regards to return types that contained@Embedded
fields.
Bug Fixes
- Fixed a bug where Room would not correctly detect the JDK version used to enable incremental annotation processor. Thanks to Blaz Solar (me@blaz.solar) (b/155215201)
- Room now embeds its ANTLR dependency with the annotation processor to avoid version conflicts with other processors that also use ANTLR. (b/150106190)
Version 2.2.6
Version 2.2.6
December 16, 2020
androidx.room:room-*:2.2.6
is released. Version 2.2.6 contains these commits.
Bug Fixes
- Fixed an issue where Room would incorrectly disabled incremental annotation processing in newer JDK versions. (b/171387388)
Version 2.2.5
Version 2.2.5
March 18, 2020
androidx.room:room-*:2.2.5
is released. Version 2.2.5 contains these commits.
Bug Fixes
- Make
MultiInstanceInvalidationService
directBootAware. Thanks to ‘Mygod contact-git@mygod.be’ (b/148240967) - Fixed a bug that would cause a crash when multi-instance invalidation was enabled and the database contained a FTS entity. (b/148969394)
- Fixed an issue when loading the SQLite native libraries in the Room annotation processor that would cause the compiler to crash due to parallel compilations. (b/146217083)
Version 2.2.4
Version 2.2.4
February 19, 2020
androidx.room:room-common:2.2.4
, androidx.room:room-compiler:2.2.4
, androidx.room:room-guava:2.2.4
, androidx.room:room-ktx:2.2.4
, androidx.room:room-migration:2.2.4
, androidx.room:room-runtime:2.2.4
, androidx.room:room-rxjava2:2.2.4
, and androidx.room:room-testing:2.2.4
are released. Version 2.2.4 contains these commits.
Bug Fixes
- Fixed an issue with suspending transactions where they would deadlock if the coroutine was canceled quickly before the transaction actually started. (b/148181325)
- Fixed an issue with the @Generated being wrongly used when building with JDK 9. (b/146538330)
- Fixed an issue where Room would generate incorrect code when a DAO interface in Kotlin had a concrete function. (b/146825845)
Version 2.2.3
Version 2.2.3
December 18, 2019
androidx.room:room-*:2.2.3
is released. Version 2.2.3 contains these commits.
Bug fixes
- Fixed a bug where Room would fail to validate a database that had not gone through any migration and contained a legacy hash with indices in its schema. (b/139306173)
Version 2.2.2
Version 2.2.2
November 20, 2019
androidx.room:room-*:2.2.2
is released. Version 2.2.2 contains these commits.
Bug fixes
- Fixed a bug where collecting a one-to-one relationship with more than 999 rows would cause Room to return null relating items. (b/143105450)
Version 2.2.1
Version 2.2.1
October 23, 2019
androidx.room:room-*:2.2.1
is released. Version 2.2.1 contains these commits.
Bug fixes
- Fixed a bug where Room would incorrectly warn about
CURSOR_MISMATCH
with the compiler optionexpandProjection
turned ON. (b/140759491) - Added a retry mechanism for handling the missing native library used for verifying queries during compile time.
Version 2.2.0
Version 2.2.0
October 9, 2019
androidx.room:room-*:2.2.0
is released. Version 2.2.0 contains these commits.
Important changes since version 2.1.0
- Pre-packaged Database: Two new APIs in
RoomDatabase.Builder
are now available for creating aRoomDatabase
given an already populated database file.createFromAsset()
is for when the pre-populated database file is in the assets folder of the APK, whilecreateFromFile()
is for when the file is in an arbitrary location. The usages of these API change the behaviour of destructive migrations such that during a fallback migration, Room will try to re-copy the pre-populated database if available, otherwise it fallbacks to just dropping and re-creating all tables. b/62185732 - Schema Default Values:
@ColumnInfo
now has a new propertydefaultValue
that can be used to specify the default value of a column. Default values are part of a database schema and will be validated during migrations if specified. b/64088772 - Many-to-Many Relations:
@Relation
now has a new propertyassociateBy
, that takes in a new annotation@Junction
, used to declare a relation that needs to be satisfied via a junction table (also known as a join table). b/69201917 - One-to-One Relations: The restriction in POJO fields annotated with
@Relation
to be of typeList
orSet
has been lifted, effectively allowing single-value relations to be represented. b/62905145 - Target Entity: The DAO annnotations
@Insert
,@Update
and@Delete
now has a new propertytargetEntity
, that allows specifying the target table the DAO method is meant to act on. This allows for the parameters of those DAO methods to be arbitrary POJOs which will be interpreted as partial entities. In practice, this allows partial inserts, deletes and updates. b/127549506 - Coroutines Flow:
@Query
DAO methods can now be of return typeFlow<T>
. The returned Flow will re-emit a new set of values if the observing tables in the query are invalidated. Declaring a DAO function with aChannel<T>
return type is an error, Room instead encourages you to useFlow
and then use the neighboring functions to convert theFlow
into aChannel
. b/130428884 - Gradle Incremental Annotation Processor: Room is now a Gradle isolating
annotation processor and incrementability can be enabled via the processor
option
room.incremental
. See Room Compiler Options for more information. If you encounter any issues please file a bug here. We plan to enable incrementability by default in a future, stable version. b/112110217 - Expanding Projections: A new experimental compiler option
room.expandProjection
was added that causes Room to rewrite a query with a star projection to only contain the columns in the returning type POJO. For example, for a DAO method with@Query("SELECT * FROM Song")
that returns a POJO namedSongIdAndTitle
with only two fields. Then Room will rewrite the query toSELECT id, title FROM Song
such that the minimum set of columns to satisfy the return type are fetched. This essentially eliminates theCURSOR_MISMATCH
warning that is presented when the query returns extra columns that do not match any field in the returning POJO type.
Version 2.2.0-rc01
September 5, 2019
androidx.room:room:2.2.0-rc01
is released. The commits included in this version can be found here.
No public changes since Room 2.2.0-beta01
.
Version 2.2.0-beta01
August 22, 2019
androidx.room:room-*:2.2.0-beta01
is released. The commits included in this version can be found here.
Bug fixes
- Fixed a bug where a Coroutine Flow query would stop reemitting new values after a certain time. (b/139175786)
- Fixed a bug where Room would not accept a legacy schema hash code while opening a database that had not gone a migration since Room 1.0, causing a runtime crash due to invalid schema. (b/139306173)
Version 2.2.0-alpha02
August 7, 2019
androidx.room:room-*:2.2.0-alpha02
is released. The commits included in this version can be found here.
New Features
- Coroutines Flow:
@Query
DAO methods can now be of return typeFlow<T>
. The returned Flow will re-emit a new set of values if the observing tables in the query are invalidated. Declaring a DAO function with aChannel<T>
return type is an error, Room instead encourages you to useFlow
and then use the neighboring functions to convert theFlow
into aChannel
. b/130428884 - Expanding Projections: A new experimental compiler option
room.expandProjection
was added that causes Room to rewrite a query with a star projection to only contain the columns in the returning type POJO. For example, for a DAO method with@Query("SELECT * FROM Song")
that returns a POJO namedSongIdAndTitle
with only two fields. Then Room will rewrite the query toSELECT id, title FROM Song
such that the minimum set of columns to satisfy the return type are fetched. This essentially eliminates theCURSOR_MISMATCH
warning that is presented when the query returns extra columns that do not match any field in the returning POJO type. onDestructiveMigrate
is a new callback API added toRoomDatabase.Callback
for when Room destructively migrates a database. b/79962330
Bug Fixes
- Fixed a bug where Room would generate incorrect code using a method as field setter when the field is protected. b/136194628
- Fixed a bug that caused the InvalidationTracker to throw a NPE in a second process when multi-instance invalidation was enabled and the invalidation Service was killed. b/137454915
- Fixed a bug where Room would not correctly identify the return type of an
inherited suspend function annotated with
@RawQuery
. b/137878827 - Updated the generated code for
@Relation
when the relating key is of type BLOB to use aByteBuffer
that is comparable. b/137881998 - Fixed a bug where Room would complain about missing setters on POJOs used as
partial entity parameters of
@Insert
,@Update
and@Delete
. b/138664463 - Fixed a bug where Room would complain about missing getters & setters for an
ignored column via
@Entity
when the entity class was used in certain DAO methods. b/138238182 - Fixed a bug where Room would not correctly convert named binding args to positional args causing a runtime exception when executing a query with re-used parameters. b/137254857
Version 2.2.0-alpha01
July 10, 2019
New Features
- Pre-packaged Database: Two new APIs in
RoomDatabase.Builder
are now available for creating aRoomDatabase
given an already populated database file.createFromAsset()
is for when the pre-populated database file is in the assets folder of the APK, whilecreateFromFile()
is for when the file is in an arbitrary location. The usages of these API change the behaviour of destructive migrations such that during a fallback migration, Room will try to re-copy the pre-populated database if available, otherwise it fallbacks to just dropping and re-creating all tables. b/62185732 - Schema Default Values:
@ColumnInfo
now has a new propertydefaultValue
that can be used to specify the default value of a column. Default values are part of a database schema and will be validated during migrations if specified. b/64088772Note: If your database schema already has default values, such as those added via
ALTER TABLE x ADD COLUMN y INTEGER NOTNULL DEFAULT z
, and you decide to define default values via@ColumnInfo
to the same columns, then you might need to provide a migration to validate the unaccounted default values. See Room Migrations for more information. - Many-to-Many Relations:
@Relation
now has a new propertyassociateBy
, that takes in a new annotation@Junction
, used to declare a relation that needs to be satisfied via a junction table (also known as a join table). b/69201917 - One-to-One Relations: The restriction in POJO fields annotated with
@Relation
to be of typeList
orSet
has been lifted, effectively allowing single-value relations to be represented. b/62905145 - Target Entity: The DAO annnotations
@Insert
,@Update
and@Delete
now has a new propertytargetEntity
, that allows specifying the target table the DAO method is meant to act on. This allows for the parameters of those DAO methods to be arbitrary POJOs which will be interpreted as partial entities. In practice, this allows partial inserts, deletes and updates. b/127549506 - Gradle Incremental Annotation Processor: Room is now a Gradle isolating
annotation processor and incrementability can be enabled via the processor
option
room.incremental
. See Room Compiler Options for more information. If you encounter any issues please file a bug here. We plan to enable incrementability by default in a future, stable version. b/112110217
Bug Fixes
- Room will no longer propagate the
EmptySetResultException
to the global error handler when the Rx stream of a query has been disposed before the query is complete. b/130257475 - Fixed a bug where Room would show an incorrect error message when a suspend
DAO function annotated with
@RawQuery
didn't have a return type. b/134303897 - Room will no longer generate DAO adapters with raw types. b/135747255
Version 2.1.0
Version 2.1.0
June 13, 2019
Room 2.1.0 is released with no changes from 2.1.0-rc01
. The commits included in the version can be found here.
Important changes since 2.0.0
- FTS: Room now supports entities with a mapping
FTS3 or FTS4 table. Classes annotated with
@Entity
can now be additionally annotated with@Fts3
or@Fts4
to declare a class with a mapping full-text search table. FTS options for further customization are available via the annotation’s methods. - Views: Room now supports declaring a class as a stored query, also known
as a view, using the
@DatabaseView
annotation. - Couroutines: DAO methods can now be suspend functions. Include
room-ktx
in your dependencies to take advantage of this functionality. The ktx artifact also provides the extension functionRoomDatabase.withTransaction
for performing database transactions within a coroutine. - Auto Value: Room now supports declaring
AutoValue
annotated classes as entities and POJOs. The Room annotations
@PrimaryKey
,@ColumnInfo
,@Embedded
and@Relation
can now be declared in an auto value annotated class’s abstract methods. Note that these annotation must also be accompanied by@CopyAnnotations
for Room to properly understand them. - Additional Async Support: DAO methods annotated with
@Insert
,@Delete
or@Update
, along with@Query
containingINSERT
,DELETE
orUPDATE
statements, now support Rx return typesCompletable
,Single
,Maybe
, and Guava's return typeListenableFuture
, and they can also be suspend functions. enableMultiInstanceInvalidation
is a new API inRoomDatabase.Builder
to enable invalidation across multiple instances of RoomDatabase using the same database file.fallbackToDestructiveMigrationOnDowngrade
is a new API inRoomDatabase.Builder
to automatically re-create the database if a downgrade happens.ignoredColumns
is a new API in the@Entity
annotation that can be used to list ignored fields by name.- Room will now properly use Kotlin’s primary constructor in data classes
avoiding the need to declare the properties as
vars
.
Version 2.1.0-rc01
May 29, 2019
Bug Fixes
- Fixed a Room initialization error that might occur due to an already setup temp_store configuration. b/132602198
- Fixed a double quote usage warning for users with SQLite 3.27.0 and above. b/131712640
- Fixed a bug where the InvalidationTracker would cause a crash when multiple invalidation checks would occur in parallel. b/133457594
Version 2.1.0-beta01
May 7, 2019
androidx.room 2.1.0-beta01
is released with no changes from 2.1.0-alpha07. The commits included in this version can be found here.
Version 2.1.0-alpha07
April 25, 2019
API / Behavior Changes
- The extension function
RoomDatabase.withTransaction
has been changed to no longer take a function block with aCoroutineScope
as receiver. This prevents skipping the additionalcoroutineScope { }
wrapper required to run things in the transaction block concurrently.
Bug Fixes
- Fixed a bug where Room would fail to match a TypeConverter for a Kotlin DAO function containing a parameter of Collection type. b/122066791
Version 2.1.0-alpha06
March 22, 2019
API / Behavior Changes
- Async transaction queries are now serialized such that Room will not use
more than one thread for executing database transactions.
RoomDatabase.Builder.setTransactionExecutor(Executor)
was added to allow configuring the executor to be used for transactions. RoomDatabase.runInTransaction(Callable)
will no longer wrap checked exceptions into RuntimeExceptions. b/128623748
Bug Fixes
- Fixed a bug where the invalidation tracker would stop observing a content table if observers for both the content table and an external content FTS table were added. b/128508917
- Updated Room's SQLite grammar to match SQLite 3.24.0. b/110883668
Version 2.1.0-alpha05
March 13, 2019
New Features
- The extension function
RoomDatabase.withTransaction
allows you to safely perform database transactions within a coroutine. Room extensions functions along with coroutines support are available in theroom-ktx
artifact. - Non-abstract DAO methods annotated with
@Transaction
can now be suspend functions. b/120241587
API / Behavior Changes
- The artifact
room-coroutines
has been renamed toroom-ktx
following the same naming as other androidx artifacts. beginTransaction
,setTransactionSuccessful
andendTransaction
inRoomDatabase
have been deprecated in favor ofrunInTransaction
and theroom-ktx
extension functionwithTransaction
.
Bug Fixes
- Fixed a bug where tokenizer arguments were being dropped if the tokenizer used was SIMPLE. b/125427014
- Fixed a bug where Room would fail to correctly identify suspending functions with parameters whos type were an inner class. b/123767877
- Fixed a bug where deferred
@Query
DAO method withINSERT
,UPDATE
orDELETE
statements were eagerly preparing the query in the main thread. b/123695593 - Fixed various bugs where Room would generate incorrect code for certain suspend functions. b/123466702 and b/123457323
- Fixed a bug where deprecated usage of methods were not being correctly suppressed in generated code. b/117602586
- Updated Room dependency of androidx.sqlite to 1.0.2 which contain fixes for correctly handling corrupted databases. b/124476912
Known Issues
- Room 2.1.0-alpha05 depends on the
kotlinx-metadata-jvm
artifact which is not currently available in Maven Central (KT-27991). This dependency can be resolved by addingmaven { url "https://kotlin.bintray.com/kotlinx/" }
to your project repositories.
Version 2.1.0-alpha04
January 25, 2019
New Features
- DAO methods annotated with
@Query
containingINSERT
,UPDATE
orDELETE
statements can now return async typesSingle
,Mayble
,Completable
andListenableFuture
. Additionally they can also be suspend functions. b/120227284
API / Behavior Changes
- Room will now throw an error if a non-abstract DAO method annotated with
@Transaction
returns an async type such asSingle
,Mayble
,Completable
,LiveData
orListenableFuture
. Since transactions are thread confined it is currently impossible for Room to begin and end a transaction around a function that may peform queries in different threads. b/120109336 OnConflictStrategy.FAIL
andOnConflictStrategy.ROLLBACK
have been@Deprecated
since they do not behave as intended with Android's current SQLite bindings. b/117266738
Bug Fixes
- Fixed a bug where Room wouldn't correctly use the TypeConverter of a return type if the DAO method was a suspend function. b/122988159
- Fixed a bug where Room would incorrectly identify inherited suspend functions as non-suspending. b/122902595
- Fixed a bug where Room would generate incorrect code when an
@Embedded
field was in a parent class and used in multiple child classes. b/121099048 - Fixed an issue where the database would deadlock when invoking DAO suspend functions between a
beginTransaction()
andendTransaction()
. b/120854786
Version 2.1.0-alpha03
December 4, 2018
API Changes
- The FTS
tokenizer
in@Fts3
/@Fts4
now takes a String instead of an Enum. This allows custom tokenizers to be used by Room. Built-in tokenizers are still defined inFtsOptions
as string constants. b/119234881
New Features
- Couroutines: DAO methods can now be suspend functions. To support suspend functions in Room a new artifact has been released,
room-coroutines
. b/69474692 - DAO methods annotated with
@Insert
,@Delete
or@Update
now supportListenableFuture
as return type. b/119418331
Bug Fixes
- Fixed a bug where Room would incorrectly attempt to find a constructor with columns in the
ignoredColumns
property of@Entity
. b/119830714 - Fixed a bug where Room would not mark DAO method parameters as final in their generated implementation. b/118015483
- Fixed a bug where Room's processor would crash when reporting an error on a query with special symbols. b/119520136
- Fixed a bug where Room would decline other various
Collection
implementations as arguments of anIN
expression. b/119884035 - Fixed a bug where LiveData returned from Room would get garbage collected when observed forever causing it to no longer emit new data. b/74477406
- Updated
RoomDatabase
's close lock to reduce lock contention. b/117900450
Version 2.1.0-alpha02
October 30, 2018
New Features
- Added support for referencing a
@DatabaseView
in a@Relation
. b/117680932
Bug Fixes
- Fixed a bug where Room would perform disk I/O in the main thread when subscribing and disposing from an Rx return type. b/117201279
- Fixed a bug where Room would fail to find an appropriate type converter for a field in a Kotlin entity class. b/111404868
- Fixed a bug where Room would generate incorrect code for a
DAO
interface implementation containing a Kotlin default method that has no arguments. b/117527454 - Updated Room's SQLite grammar parser, fixing a performance issue that would cause long build times. b/117401230
Version 2.1.0-alpha01
October 8, 2018
New Features
- FTS: Room now supports entities with a mapping FTS3 or FTS4 table. Classes annotated with
@Entity
can now be additionally annotated with@Fts3
or@Fts4
to declare a class with a mapping full-text search table. FTS options for further customization are available via the annotation’s methods. b/62356416 - Views: Room now supports declaring a class as a stored query, also known as a view using the @DatabaseView annotation. b/67033276
- Auto Value: Room now supports declaring AutoValue annotated classes as entities and POJOs. The Room annotations
@PrimaryKey
,@ColumnInfo
,@Embedded
and@Relation
can now be declared in an auto value annotated class’ abstract methods. Note that these annotation must also be accompanied by@CopyAnnotations
for Room to properly understand them. b/62408420 - Additional Rx Return Types Support: DAO methods annotated with
@Insert
,@Delete
or@Update
now support Rx return typesCompletable
,Single<T>
andMaybe<T>
. b/63317956 - Immutable Types with
@Relation
: Room previously required@Relation
annotated fields to be settable but now they can be constructor parameters. enableMultiInstanceInvalidation
: Is a new API inRoomDatabase.Builder
to enable invalidation across multiple instances of RoomDatabase using the same database file. This multi-instance invalidation mechanism also works across multiple processes. b/62334005fallbackToDestructiveMigrationOnDowngrade
: Is a new API inRoomDatabase.Builder
to automatically re-create the database if a downgrade happens. b/110416954ignoredColumns
: Is a new API in the@Entity
annotation that can be used to list ignored fields by name. Useful for ignoring inherited fields on an entity. b/63522075
API / Behavior Changes
mCallback
andmDatabase
inRoomDatabase
are now@Deprecated
and will be removed in the next major version of Room. b/76109329
Bug Fixes
- Fixed two issues where Room wouldn’t properly recover from a corrupted database or a bad migration during initialization. b/111504749 and b/111519144
- Room will now properly use Kotlin’s primary constructor in data classes avoiding the need to declare the fields as
vars
. b/105769985
Version 2.0.0
Version 2.0.0
October 1, 2018
androidx.room 2.0.0
is released with no changes from 2.0.0-rc01.
Version 2.0.0-rc01
September 20, 2018
androidx.room 2.0.0-rc01
is released with no changes from 2.0.0-beta01.
Version 2.0.0-beta01
July 2, 2018
API / Behavior Changes
- Added
RoomDatabase.Builder.setQueryExecutor()
to allow customization of where queries are run - Added RxJava2
Observable
support - Generated DAO and Database implementations are now final
Bug Fixes
- Specify class/field name in "cannot find getter for field" error b/73334503
- Fixed RoomOpenHelper backwards compatibility with older versions of Room b/110197391
Pre-AndroidX Dependencies
For the pre-AndroidX versions of Room, include these dependencies:
dependencies {
def room_version = "1.1.1"
implementation "android.arch.persistence.room:runtime:$room_version"
annotationProcessor "android.arch.persistence.room:compiler:$room_version" // For Kotlin use kapt instead of annotationProcessor
// optional - RxJava support for Room
implementation "android.arch.persistence.room:rxjava2:$room_version"
// optional - Guava support for Room, including Optional and ListenableFuture
implementation "android.arch.persistence.room:guava:$room_version"
// Test helpers
testImplementation "android.arch.persistence.room:testing:$room_version"
}
Version 1.1.1
Version 1.1.1
June 19, 2018
Room 1.1.1
is identical to Room 1.1.1-rc1
.
Version 1.1.1-rc1
May 16, 2018
We highly
recommend using Room 1.1.1-rc1
instead of 1.1.0
if you are using migrations.
Fixed a bug where Room would not handle post migration initialization properly b/79362399
Version 1.1.0
Version 1.1.0-beta3
April 19, 2018
Bug Fixes
- Fix compilation error when a Kotlin POJO references a relation entity that was defined in Java b/78199923
Version 1.1.0-beta2
April 5, 2018
Bug Fixes
Fixed a critical bug in Room's Rx
Single
andMaybe
implementations where it would recycle the query ahead of time, causing problems if you add more than 1 observer to the returnedSingle
orMaybe
instancces. b/76031240[RoomDatabase.clearAllTables][ref-clearAllTables] will not
VACUUM
the database if it is called inside a transaction. b/77235565
Version 1.1.0-beta1
March 21, 2018
API Changes
- Based on API Review feedback,
@RawQuery
does not accept passing aString
as the query parameter anymore. You need to use [SupportSQLiteQuery][ref-SupportSQLiteQuery]. (see [SimpleSQLiteQuery][ref-SimpleSQLiteQuery] to easily create an instance of [SupportSQLiteQuery][ref-SupportSQLiteQuery] with argument support). - RoomDatabase.Builder's [fallbackToDestructiveMigrationFrom][ref-fallbackToDestructiveMigrationFrom] method now accepts
vararg int
instead ofvararg Integer
.
Bug Fixes
- [RoomDatabase.clearAllTables][ref-clearAllTables] now tries to return space back to the operating system by setting a WAL checkpoint and
VACUUM
ing the database. - [
@RawQuery
][ref-RawQuery] now accepts any Pojo for theobservedEntities
property as long as the Pojo references to one or more entities via itsEmbedded
fields orRelation
s. b/74041772 - Paging: Room’s DataSource implementation now correctly handles multi-table dependencies (such as relations, and joins). Previously these would fail to trigger new results, or could fail to compile. b/74128314
Version 1.1.0-alpha1
January 22, 2018
New Features
RawQuery
: This new API allows@Dao
methods to receive the SQL as a query parameter b/62103290, b/71458963fallBackToDestructiveMigrationsFrom
: This new API inRoomDatabase.Builder
allows for finer grained control over from which starting schema versions destructive migrations are allowed (as compared to fallbackToDestructiveMigration) b/64989640- Room now only supports newer Paging APIs (alpha-4+), dropping support for the deprecated
LivePagedListProvider
. To use the new Room alpha, you’ll need to use pagingalpha-4
or higher, and switch fromLivePagedListProvider
toLivePagedListBuilder
if you haven’t already.
Bug Fixes
- Improved support for Kotlin Kapt types. b/69164099
- Order of fields do not invalidate schema anymore. b/64290754