I didn't really expect this to work, but can Android Room @Relation be filtered with a WHERE
clause. For example:
SELECT * FROM meta WHERE subjectId IN (?)
@RawQuery(observedEntities = [ MetadataEntity::class, SubjectJunction::class ])
internal abstract fun internalGetImages(query: SupportSQLiteQuery): LiveData<List<MetadataXmp>>
`
data class MetadataXmp @JvmOverloads constructor(
@Embedded
val metadata:MetadataEntity,
@Relation(
parentColumn = "id",
entityColumn = "metaId",
projection = ["subjectId"],
entity = SubjectJunction::class)
var subjectIds: List<Long> = Collections.emptyList())
This throws no such column: subjectId
. I suspect that @Relation
is only gathered based on the core query result and the relational columns are never present for the initial query, but I wanted to see if the relation could referenced.
Maybe a bit late but you can query the @Relation. You can find an example here (see tip 6).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.