Last active
September 30, 2022 10:16
-
-
Save anangkur/f3b8dc847cf60cfcd63e4311b21994b0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
data class Entity( | |
@PrimaryKey | |
val id: Int, | |
val attributes: String, | |
) | |
@Entity | |
data class Entity2( | |
@PrimaryKey | |
val id: Int, | |
val entity1Id: Int, | |
val attributes: String, | |
) | |
data class EntityMerged( | |
@Embedded | |
val entity: Entity, | |
@Relation( | |
parentColumn = "id", | |
entityColumn = "entity1Id", | |
) | |
val entity2: List<Entity2>, | |
) | |
@Dao | |
interface RoomDao { | |
@Insert | |
suspend fun insertData(entity: Entity) | |
@Query("select * from entity join entity2 on entity.id = entity2.entity1Id join entity3 on entity.id = entity3.entity1Id") | |
suspend fun getAllData(): List<EntityMerged> | |
@Query("select * from entity join entity2 on entity.id = entity2.entity1Id join entity3 on entity.id = entity3.entity1Id") | |
suspend fun getAllData2(): Map<Entity, EntityMerged> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment