2.2.0-alpha01
https://developer.android.com/jetpack/androidx/releases/room#2.2.0-alpha01
Version 2.2.0-alpha01
July 10, 2019
New Features
-
Pre-packaged Database: Two new APIs in RoomDatabase.Builder are now
available for creating a RoomDatabase given an already populated database
file. createFromAsset() is for when the pre-populated database file is in
the assets folder of the APK, while createFromFile() 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 property defaultValue
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
Note: 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 property associateBy,
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 type List or Set 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 property targetEntity, 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