Fixed
Status Update
Comments
da...@google.com <da...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
Description
Version used: 2.2.0-alpha01
Devices/Android versions reproduced on: Pixel 3 XL / Android P
I've tried to use the new awesome Target Entity feature that introduced at 2.2.0-alpha01.
But, I encountered the Room compiler error.
It seems to happen if try inserting immutable data class using @Insert(entity = ImmutableDataClass::class)
The error message says "Cannot find setter for field.". But, the generated Dao_Impl code does not use the setter methods.
Is this a Room compiler bug?
The workaround is replacing val to var.
Here is sample codes:
```
@Database(entities = [Project::class], version = 1)
abstract class TargetEntityDatabase : RoomDatabase() {
abstract fun projectDao(): ProjectDao
}
@Entity
data class Project(
@PrimaryKey
val id: Long,
val title: String,
@ColumnInfo(defaultValue = "''")
val longDescription: String
)
data class ProjectMiniApiEntity(
val id: Long,
val title: String
)
@Dao
interface ProjectDao {
@Insert(entity = Project::class)
fun insertNewProject(projectMini: ProjectMiniApiEntity)
}
```
Gradle logs:
```
> Task :app:kaptDebugKotlin FAILED
e: ProjectMiniApiEntity.java:20: error: Cannot find setter for field.
private final long id = 0L;
^
e: ProjectMiniApiEntity.java:22: error: Cannot find setter for field.
private final java.lang.String title = null;
^
```