Skip to content

Instantly share code, notes, and snippets.

@anangkur
Last active September 30, 2022 10:13
Show Gist options
  • Save anangkur/8473cf57f8dae89e871e0f823d463825 to your computer and use it in GitHub Desktop.
Save anangkur/8473cf57f8dae89e871e0f823d463825 to your computer and use it in GitHub Desktop.
@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