error: Not sure how to handle query method's return type Unexcepter error in DbDao class after rebuild project. Until that point, everything worked great and nothing was done in that class or anything that had anything to do with that library, but all of a sudden it started throwing out bugs within the generated java file
ERROR: D:\workspace\workspace\Android studio\CorralApp\ProjectCoral\app\build\tmp\kapt3\stubs\debug\com\mmscode\coralproject\db\DbDao.java:21: error: Not sure how to handle query method's return type (java.lang.Object). DELETE query methods must either return void or int (the number of deleted rows). public abstract java.lang.Object deleteUser(@org.jetbrains.annotations.NotNull() ^
And for example, if i delete function deleteUser, this error will be show on an other function
Code:
package com.mmscode.coralproject.db
import androidx.lifecycle.LiveData
import androidx.room.*
@Dao
abstract class DbDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertUserData(user: DbUser)
@Query("DELETE FROM DbUser")
abstract suspend fun deleteUser()
@Query("SELECT * FROM DbUser")
abstract suspend fun getUser(): DbUser?
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertDailySchedule(list: List<DbSchedule>)
@Query("SELECT * FROM DbSchedule where scheduleStatusName NOT LIKE 'ENDED' ORDER BY eventTime")
abstract fun getDailySchedule(): LiveData<List<DbSchedule>>?
@Query("SELECT * FROM DbSchedule where scheduleStatusName NOT LIKE 'ENDED' AND date(substr(dateFrom,7,4)|| '-' ||substr(dateFrom,1,2)|| '-'||substr(dateFrom,4,2)) > date(:date,'start of month', '-1 month', '-10 day')")
abstract suspend fun getDailySchedule2(date: String): List<DbSchedule>
@Query("SELECT * FROM DbSchedule where scheduleStatusName NOT LIKE 'ENDED' ORDER BY eventTime")
abstract suspend fun getDailySchedule3(): List<DbSchedule>
@Query("SELECT * FROM DbSchedule where scheduleStatusName NOT LIKE 'ENDED' and date(substr(dateFrom,7,4)|| '-' ||substr(dateFrom,1,2)|| '-'||substr(dateFrom,4,2)) between DATE(:dateFrom) AND DATE(:dateTo) ORDER BY eventTime")
abstract suspend fun getSchedules(dateFrom: String, dateTo: String): List<DbSchedule>
@Query("SELECT statusId from DbSchedule WHERE careId = :careId")
abstract suspend fun getStatusId(careId: Int): Int
@Query("UPDATE DbSchedule SET scheduleStatusName = :scheduleStatusName WHERE scheduleId = :scheduleId")
abstract suspend fun updateReminder(scheduleId: Int, scheduleStatusName: String)
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertBreeds(list: List<DbBreeds>)
@Query("SELECT * FROM DbBreeds where speciesname = :speciesName ORDER BY breedname")
abstract suspend fun getBreeds(speciesName: String?): List<DbBreeds>?
@Query("SELECT speciesname FROM DbBreeds GROUP BY speciesname ORDER BY speciesname")
abstract fun getSpecies(): LiveData<List<String>>?
@Query("SELECT * FROM DbCareProviders WHERE category_name = :category and valid = 'Y'")
abstract suspend fun getProviders(category: String?): List<DbCareProviders>
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertProviders(list: List<DbCareProviders>)
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertNotifications(list: List<DBNotifications>)
@Query("SELECT * FROM DBNotifications order by receive_date desc")
abstract suspend fun getAllNotifications(): List<DBNotifications>
@Query("SELECT COUNT(*) from DBNotifications WHERE upper(message_status_name) = 'UNREAD'")
abstract suspend fun getCountUnreadNotifications(): Int
@Query("UPDATE DBNotifications SET message_status_name='OPEN_NOT_READ' where message_status_name = 'UNREAD'")
abstract suspend fun readNotifications()
@Query("UPDATE DBNotifications SET message_status_name='READ' WHERE notification_id=:id")
abstract suspend fun openNotification(id: Int)
@Query("UPDATE DBNotifications SET message_status_name='READ'")
abstract suspend fun openAllNotification()
@Query("UPDATE DBNotifications SET member_status_name='ACTIVE' WHERE notification_id=:id")
abstract suspend fun acceptFriendRequest(id: Int)
@Query("UPDATE DBNotifications SET member_status_name='INACTIVE' WHERE notification_id=:id")
abstract suspend fun ignoreFirenRequest(id: Int)
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertCareActivities(list: List<DBCareActivities>)
@Query("SELECT * FROM DBCareActivities")
abstract suspend fun getCareActivities(): List<DBCareActivities>
@Insert(onConflict = OnConflictStrategy.REPLACE)
abstract suspend fun insertUserAccounts(list: List<DbUserAccounts>)
/* @Update(entity = DBNotifications::class)
abstract fun ReadNotifications(notifications: List<DBNotifications> )*/
}
EDIT: last room version 2.3.0
// Room
implementation "androidx.room:room-runtime:2.3.0"
kapt "androidx.room:room-compiler:2.3.0"
// Room ktx
implementation 'androidx.room:room-ktx:2.3.0'