Last active
September 30, 2022 10:13
-
-
Save anangkur/8473cf57f8dae89e871e0f823d463825 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, | |
) | |
@Entity | |
data class Entity3( | |
@PrimaryKey | |
val id: Int, | |
val entity1Id: Int, | |
val attributes: String, | |
) | |
data class EntityMerged( | |
@Embedded | |
val entity: Entity, | |
@Embedded | |
val entity2: Entity2, | |
@Embedded | |
val entity3: Entity3, | |
) | |
@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> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment