[ad_1]
I had the same problem. Let me walk you through the example on how I ended up to the problem and the way I resolved it perhaps you can get a bigger picture.
Before resolving
@Entity(tableName = "modules")
data class Module
(
@PrimaryKey val id: Int,
val name: String
)
@Entity(tableName = "sessions")
data class Session
(
@PrimaryKey(autoGenerate = true) var id: Int,
@ColumnInfo(name = "module_id") val moduleId: Int,
@ColumnInfo(name = "start_time") val startTime: String,
@ColumnInfo(name = "end_time") val endTime: String
)
data class ModuleSession
(
@Embedded val module: Module,
@Relation(
parentColumn = "id",
entityColumn = "module_id"
)
val sessions: List<Session>,
@ColumnInfo(name = "is_updated") val isUpdated: Boolean = false // The problem
)
In the DAO
@Transaction
@Query("SELECT * FROM modules")
abstract suspend fun getModuleSession(): List<ModuleSession>
The error I got was
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution
So I dug deeper and found the below message
The columns returned by the query does not have the fields [isUpdated] in com.gmanix.oncampusprototype.Persistence.ModuleSession even though they are annotated as non-null or primitive. Columns returned by the query: [id,name]
public abstract java.lang.Object getModuleSession(@org.jetbrains.annotations.NotNull()
I removed the field IsUpdated from the POJO ModuleSession and added it to the session table
After changes
@Entity(tableName = "sessions")
data class Session
(
@PrimaryKey(autoGenerate = true) var id: Int,
@ColumnInfo(name = "module_id") val moduleId: Int,
@ColumnInfo(name = "start_time") val startTime: String,
@ColumnInfo(name = "end_time") val endTime: String,
@ColumnInfo(name = "is_updated") val isUpdated: Boolean = false
)
data class ModuleSession
(
@Embedded val module: Module,
@Relation(
parentColumn = "id",
entityColumn = "module_id"
)
val sessions: List<Session>
)
On the other hand crosscheck if there is any field on the SELECT
statement that is a suspect causing issues or you can annotate it with @Ignore
However you can post your code if you’re still not comfortable.
I hope that might help
[ad_2]