My android application has the following room dao function
@RawQuery
@Transaction
abstract suspend fun queryOneOrNone(query: SupportSQLiteQuery): TEntity?
kapt generates the following java code:-
@Override
public Object queryOneOrNone(final SupportSQLiteQuery query,
final Continuation<? super MyEntity> $completion) {
final CancellationSignal _cancellationSignal = DBUtil.createCancellationSignal();
return CoroutinesRoom.execute(__db, true, _cancellationSignal, new Callable<MyEntity>() {
@Override
@Nullable
public MyEntity call() throws Exception {
__db.beginTransaction();
try {
final Cursor _cursor = DBUtil.query(__db, query, false, null);
try {
final MyEntity _result;
if (_cursor.moveToFirst()) {
_result = __entityCursorConverter_persistenceStorageMyEntity(_cursor);
} else {
_result = null;
}
__db.setTransactionSuccessful();
return _result;
} finally {
_cursor.close();
}
} finally {
__db.endTransaction();
}
}
}, $completion);
}
Where as ksp generates this:-
public override suspend fun queryOneOrNone(query: SupportSQLiteQuery):
MyEntity? {
val _cancellationSignal: CancellationSignal? = createCancellationSignal()
return execute(__db, true, _cancellationSignal, object :
Callable<MyEntity?> {
public override fun call(): MyEntity? {
__db.beginTransaction()
try {
val _cursor: Cursor = query(__db, query, false, null)
try {
val _result: MyEntity
if (_cursor.moveToFirst()) {
_result =
__entityCursorConverter_persistenceStorageMyEntity(_cursor)
} else {
error("The query result was empty, but expected a single row to return a NON-NULL object of type <MyEntity>.")
}
__db.setTransactionSuccessful()
return _result
} finally {
_cursor.close()
}
} finally {
__db.endTransaction()
}
}
})
}
and my application fails with....
"The query result was empty, but expected a single row to return a NON-NULL object of type <MyEntity>."
is this a ksp issue? or have i made a mistake in my application?
by adding:-
ksp {
arg("room.generateKotlin", "false")
}
to my gradle i can mitigate this error, however it would be prefferable to have ksp generate kotlin.