Reputation: 275
I am in this process of converting my application to Kotlin multiplatform using room. The database entries (@Database, @Entity and @ DAO) for Room have been converted without any error (so far).
My gradle entries for the project are using Room version 2.7.0-alpha05
All of my Room database processes (insert, query, update and delete) are contained in my MainViewModel.
All of the MainViewModel database processes have compiled successfully (no errors) except for two insert functions. Inserts for 19 entities all have compiled OK. Each insert follows the same approach (see below), however these two have an "unresolved" error on the DAO for those entries.
The two insert functions in question use the same DAO data element name that is used in other query and delete processes. Confirmed simply by searching in Android Studio for the data element name (checking for caps and not caps).
The following is the DAO entires for the inserts that are not working. Inserts are the first entries in the DAO.
@Dao
interface CustomGeofencePerimeterMarkerTableDao{
@Insert
fun insertCustomGeofencePerimeterMarkerTable(customGeofencePerimeterMarkerTable: CustomGeofencePerimeterMarkerTable): Long?
@Query("DELETE FROM CustomGeofencePerimeterMarkerTable WHERE customGeofencePerimeterMarkerTablePrimaryKey = :customGeofencePerimeterMarkerTablePrimaryKey")
fun deleteCustomGeofencePerimeterMarkerTable(customGeofencePerimeterMarkerTablePrimaryKey: Long)
@Query("DELETE FROM CustomGeofencePerimeterMarkerTable")
fun deleteAllCustomGeofencePerimeterMarkerTables()
@Query("SELECT * FROM CustomGeofencePerimeterMarkerTable")
fun findAllCustomGeofencePerimeterMarker(): MutableList<CustomGeofencePerimeterMarkerTable?>?
@Query("SELECT * FROM CustomGeofencePerimeterMarkerTable WHERE customGeofencePerimeterMarkerContactAddressTableFirebaseKey = :customGeofencePerimeterMarkerContactAddressTableFirebaseKey")
fun findAllCustomGeofencePerimeterMarkerByContactAddressFirebaseKey(
customGeofencePerimeterMarkerContactAddressTableFirebaseKey: String?
): CustomGeofencePerimeterMarkerTable?
@Query("SELECT * FROM CustomGeofencePerimeterMarkerTable WHERE customGeofencePerimeterMarkerTableFirebaseKey = :customGeofencePerimeterMarkerTableFirebaseKey")
fun findCustomGeofencePerimeterMarkerTableByFirebaseKey(
customGeofencePerimeterMarkerTableFirebaseKey: String?
): CustomGeofencePerimeterMarkerTable?
@Query(
"UPDATE CustomGeofencePerimeterMarkerTable SET " +
"customGeofencePerimeterMarkerTablePrimaryKey = :customGeofencePerimeterMarkerTablePrimaryKey, " +
"customGeofencePerimeterMarkerTableFirebaseKey = :customGeofencePerimeterMarkerTableFirebaseKey, " +
"customGeofencePerimeterMarkerContactAddressTableFirebaseKey = :customGeofencePerimeterMarkerContactAddressTableFirebaseKey, " +
"customGeofencePerimeterMarkerDateAndTime = :customGeofencePerimeterMarkerDateAndTime, " +
"customGeofencePerimeterMarkerString = :customGeofencePerimeterMarkerString " +
"WHERE customGeofencePerimeterMarkerTablePrimaryKey = :customGeofencePerimeterMarkerTablePrimaryKey"
)
fun updateCustomGeofencePerimeterMarkerTable(
customGeofencePerimeterMarkerTablePrimaryKey: Long,
customGeofencePerimeterMarkerTableFirebaseKey: String?,
customGeofencePerimeterMarkerContactAddressTableFirebaseKey: String?,
customGeofencePerimeterMarkerDateAndTime: String?,
customGeofencePerimeterMarkerString: String?
)
}
@Dao
interface CurrentLocationTableDao{
@Insert
fun insertCurrentLocation(currentLocationTable: CurrentLocationTable): Long?
@Query("DELETE FROM CurrentLocationTable WHERE currentLocationTablePrimaryKey = :currentLocationTablePrimaryKey")
fun deleteCurrentLocation(currentLocationTablePrimaryKey: Long)
@Query("DELETE FROM CurrentLocationTable WHERE currentLocationTableFirebaseKey = :currentLocationTableFirebaseKey")
fun deleteCurrentLocationByCurrentLocationFirebaseKey(currentLocationTableFirebaseKey: String?)
@Query("DELETE FROM CurrentLocationTable")
fun deleteAllCurrentLocations()
@get:Query("SELECT * FROM CurrentLocationTable")
val allCurrentLocation: LiveData<MutableList<CurrentLocationTable?>?>
@Query("SELECT * FROM CurrentLocationTable WHERE currentLocationContactEmailAddress = :currentLocationContactEmailAddress ORDER BY currentLocationSequenceKey ASC")
fun findAllCurrentLocation(currentLocationContactEmailAddress: String?): MutableList<CurrentLocationTable?>?
@Query("SELECT * FROM CurrentLocationTable WHERE currentLocationTableFirebaseKey = :currentLocationTableFirebaseKey")
fun findCurrentLocationTableByFirebaseKey(currentLocationTableFirebaseKey: String?): CurrentLocationTable?
@Query("SELECT * FROM CurrentLocationTable WHERE currentLocationTablePrimaryKey = :currentLocationTablePrimaryKey")
fun findCurrentLocationByCurrentLocationTablePrimaryKey(currentLocationTablePrimaryKey: Long): CurrentLocationTable?
@Query(
"UPDATE CurrentLocationTable SET " +
"currentLocationTablePrimaryKey = :currentLocationTablePrimaryKey, " +
"currentLocationTableFirebaseKey = :currentLocationTableFirebaseKey, " +
"currentLocationContactEmailAddress = :currentLocationContactEmailAddress, " +
"currentLocationTransactionType = :currentLocationTransactionType, " +
"currentLocationSequenceKey = :currentLocationSequenceKey, " +
"currentLocationAndDateTimeString = :currentLocationAndDateTimeString " +
"WHERE currentLocationTablePrimaryKey = :currentLocationTablePrimaryKey"
)
fun updateCurrentLocation(
currentLocationTablePrimaryKey: Long,
currentLocationTableFirebaseKey: String?,
currentLocationContactEmailAddress: String?,
currentLocationTransactionType: String?,
currentLocationSequenceKey: Long,
currentLocationAndDateTimeString: String?
)
}
In the MainViewModel, the DAO definitions are as follows: From init {} All other DAO entries are in the same place.
val db: PeepsConnectionRoomDatabase
db = PeepsConnectionRoomDatabase.getDatabase(appContext)!!
currentLocationTableDao = db.currentLocationTableDao()!!
customGeofencePerimeterMarkerTableDao = db.customGeofencePerimeterMarkerTableDao()!!;
From the definitions in the MainViewModel class (all other definitions for DAO's are in the same place. ''' var checkInRouteAddressTableDao: CheckInRouteAddressTableDao var customGeofencePerimeterMarkerTableDao: CustomGeofencePerimeterMarkerTableDao '''
The functions for the inserts where the DAO's are unresolved.
@Throws(ExecutionException::class, InterruptedException::class)
fun insertCurrentLocation(currentLocationTable: CurrentLocationTable?): Long? {
Log.i(" ", "MainViewModel insertCurrentLocation: ")
mCurrentLocationTable = currentLocationTable
val insertCurrentLocationTask = InsertCurrentLocationTask(currentLocationTable)
val future = executor.submit(insertCurrentLocationTask) ?: null
return future?.get()
}
internal class InsertCurrentLocationTask(mCurrentLocationTable: CurrentLocationTable?) :
Callable<Long?> {
@Throws(Exception::class)
override fun call(): Long? {
return currentLocationTableDao.insertCurrentLocation(mCurrentLocationTable)
}
}
@Throws(ExecutionException::class, InterruptedException::class)
fun insertCustomGeofencePerimeterMarker(customGeofencePerimeterMarkerTable: CustomGeofencePerimeterMarkerTable?): Long? {
Log.i(" ", "MainViewModel insertCustomGeofencePerimeterMarker: ")
val insertCustomGeofencePerimeterMarkerTask =
InsertCustomGeofencePerimeterMarkerTask(customGeofencePerimeterMarkerTable)
val future = executor.submit(insertCustomGeofencePerimeterMarkerTask) ?: null
return future?.get()
}
internal class InsertCustomGeofencePerimeterMarkerTask(mCustomGeofencePerimeterMarkerTable: CustomGeofencePerimeterMarkerTable?) :
Callable<Long?> {
@Throws(Exception::class)
override fun call(): Long {
return customGeofencePerimeterMarkerTableDao.insertCustomGeofencePerimeterMarkerTable(mCustomGeofencePerimeterMarkerTable)
}
}
NOTE "currentLocationTableDao" and "customGeofencePerimeterMarkerTableDao" in the respective return statements are "unresolved" but are recognize elsewhere in the MainViewModel.
Upvotes: 0
Views: 28
Reputation: 275
Resolved. I did not have the two insert functions identified as internal "inner" class. Missed the inner parameter.
Upvotes: 0