I have a table Messages (PrimaryKey messageId) and a table ReadUpdates. Each message has many ReadUpdates that are related with
I want to query the Room Database with the below sql, and get a Map with key=Message and value=List
@Query(
"""
Select * from messages
inner join readUpdates on messages.messages_message_id = readUpdates.read_upd_message_id
where messages.messages_message_id = :messageId
and messages.messages_server_id = :serverId
"""
)
fun getMessageRecipients(
serverId: Long,
messageId: String
): LiveData<Map<Message, List<ReadUpdateAccount>>>
ReadUpdateAcccount is the model joined ReadUpdate and Account
data class ReadUpdateAccount(
@Embedded
val readUpdate: ReadUpdate,
@Relation(entity = Account::class, parentColumn = "read_upd_connection_id", entityColumn = "accounts_account_id")
val account: Account?
)
After debugging the query i see that instead of example
- <Message(AAA), [ReadUpdateAccount(111), ReadUpdateAccount(222), ReadUpdateAccount(333)]>
i have
- <Message(AAA), [ReadUpdateAccount(111)]> <Message(AAA), [ReadUpdateAccount(222)]>, <Message(AAA), [ReadUpdateAccount(333)]>
Obviously, i need the First but i get the Second Why is this happening and how can i solve this?