Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
I think it is because we've deprecated the accidently public mDatabase. Should be fine.
Can you share the full warning so we can verify?
Can you share the full warning so we can verify?
sa...@smartpatient.eu <sa...@smartpatient.eu> #3
That's the entire message:
...app\build\generated\source\kapt\remoteDevDebug\za\co\ruggedmobile\petermeter\data\PeterMeterDb_Impl.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.
...app\build\generated\source\kapt\remoteDevDebug\za\co\ruggedmobile\petermeter\data\PeterMeterDb_Impl.java:
uses or overrides a deprecated API.
Recompile with -Xlint:deprecation for details.
ap...@google.com <ap...@google.com> #4
I see it is a "Note" not a warning.
da...@google.com <da...@google.com> #5
Here are the warnings I'm getting with -Xlint:deprecation:
AppDatabase_Impl.java:154: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
if (mCallbacks != null) {
^
AppDatabase_Impl.java:155: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
for (int _i = 0, _size = mCallbacks.size(); _i < _size; _i++) {
^
AppDatabase_Impl.java:156: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
mCallbacks.get(_i).onCreate(_db);
^
AppDatabase_Impl.java:163: warning: [deprecation] mDatabase in RoomDatabase has been deprecated
mDatabase = _db;
^
AppDatabase_Impl.java:166: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
if (mCallbacks != null) {
^
AppDatabase_Impl.java:167: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
for (int _i = 0, _size = mCallbacks.size(); _i < _size; _i++) {
^
AppDatabase_Impl.java:168: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
mCallbacks.get(_i).onOpen(_db);
^
AppDatabase_Impl.java:154: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
if (mCallbacks != null) {
^
AppDatabase_Impl.java:155: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
for (int _i = 0, _size = mCallbacks.size(); _i < _size; _i++) {
^
AppDatabase_Impl.java:156: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
mCallbacks.get(_i).onCreate(_db);
^
AppDatabase_Impl.java:163: warning: [deprecation] mDatabase in RoomDatabase has been deprecated
mDatabase = _db;
^
AppDatabase_Impl.java:166: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
if (mCallbacks != null) {
^
AppDatabase_Impl.java:167: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
for (int _i = 0, _size = mCallbacks.size(); _i < _size; _i++) {
^
AppDatabase_Impl.java:168: warning: [deprecation] mCallbacks in RoomDatabase has been deprecated
mCallbacks.get(_i).onOpen(_db);
^
Description
Version used: 2.1.0
Devices/Android versions reproduced on: not related
Recently I have updated all Room calls to suspend functions and I discovered that there is an issue with suspend function annotated with @RawQuery which returns generic type.
How to reproduce it?
I'm using base dao for all my entities:
abstract class BaseDao<ENTITY> {
@RawQuery
abstract fun rawQuery(query: SupportSQLiteQuery): List<ENTITY>
}
Example entity:
@Dao
abstract class SampleDao : BaseDao<SampleEntity>()
For this setup Room generates the following implementation:
@Override
public List<SampleEntity> rawQuery(final SupportSQLiteQuery query) {
final SupportSQLiteQuery _internalQuery = query;
__db.assertNotSuspendingTransaction();
final Cursor _cursor = DBUtil.query(__db, _internalQuery, false);
try {
final List<SampleEntity> _result = new ArrayList<SampleEntity>(_cursor.getCount());
while(_cursor.moveToNext()) {
final SampleEntity _item;
_item = __entityCursorConverter_examplePackageSampleEntity(_cursor);
_result.add(_item);
}
return _result;
} finally {
_cursor.close();
}
}
Problems start when I add suspend modifier to rawQuery function:
abstract class BaseDao<ENTITY> {
@RawQuery
abstract suspend fun rawQuery(query: SupportSQLiteQuery): List<ENTITY>
}
Then Room is not able to generate correct implementation and something like that comes out:
@Override
public Object rawQuery(final SupportSQLiteQuery query,
final Continuation<? super List<? extends SampleEntity>> p1) {
final SupportSQLiteQuery _internalQuery = query;
return CoroutinesRoom.execute(__db, false, new Callable<List<? extends ENTITY>>() {
@Override
public List<? extends ENTITY> call() throws Exception {
final Cursor _cursor = DBUtil.query(__db, _internalQuery, false);
try {
return _result;
} finally {
_cursor.close();
}
}
}, p1);
}
I also saw this in 2.2.0-alpha01 and I think issue lies in the code generation.