Bradleycorn
04/13/2023, 8:42 PM@Entity(...)
data class MyEntity(
val id: Int,
val name: String,
@Ignore
val otherField: String = ""
)
Is there some way that I can make Room “ignore” otherfield
in terms of table creation and writing to the table, but use it when reading from a query and creating an instance of MyEntity
?
I’d like to make a query method like this:
@Query("SELECT me.*, sot.otherField FROM " +
"MyEntity me " +
"JOIN SomeOtherTable.sot on me.id = sot.id " +
"WHERE me.id = :id")
fun getEntity(id: Int): Flow<MyEntity>
This doesn’t work (otherField is always an empty string), I guess cause I told Room to @Ignore
it.
would be cool if I could to something like @Ignore(write=true, read=false)
or something like that.