Last active
February 8, 2023 04:44
-
-
Save parthdesai1208/6544217055cd82caa3a48e601fc225c3 to your computer and use it in GitHub Desktop.
Room
This file contains hidden or 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
//one-to-many relation | |
@Entity(tableName = "TicketGroup") | |
data class TicketGroup( | |
@PrimaryKey(autoGenerate = false) | |
val groupId: Int, | |
val groupName: String, | |
) | |
@Entity(tableName = "Ticket") | |
data class Ticket( | |
@PrimaryKey(autoGenerate = false) | |
val ticketId: Int, | |
val ticketGroupId: Int, | |
val ticketIssue: String, | |
val ticketName: String, | |
val ticketPrice: Long | |
) | |
data class TicketGroupWithTickets( | |
@Embedded val ticketGroup: TicketGroup, | |
@Relation( | |
parentColumn = "groupId", | |
entityColumn = "ticketGroupId" | |
) | |
val ticketList : List<Ticket> | |
) | |
@Transaction | |
@Query("SELECT * FROM TicketGroup") | |
suspend fun getTicketGroupWithTickets(): List<TicketGroupWithTickets> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment