0
@Entity(tableName = "subscription")
data class Subscription(
    @PrimaryKey val planId: Int,
    @ColumnInfo(name = "plan_name") val planName: String? = null,
    @ColumnInfo(name = "plan_description") val planDescription: String? = null,
    @ColumnInfo(name = "plan_reg_fee") val planRegFee: String? = null,
    @ColumnInfo(name = "plan_monthly_charge") val planMonthlyCharge: String? = null
)


data class Benefit(
    @ColumnInfo(name = "benefit_id") val benefitId: Int? = null,
    @ColumnInfo(name = "benefit_code") val benefitCode: Int? = null,
    @ColumnInfo(name = "benefit_name") val benefitName: String? = null,
    @ColumnInfo(name = "benefit_status") val benefitStatus: String? = null
)

how to get a list of Benefit inside Subscription i.e.,

val benefitList: LiveData<List<Benefit>>? = null

using Room relation

Abraham Mathew
  • 2,029
  • 3
  • 21
  • 42

1 Answers1

0

You can find examples from Google Documents. There are examples about Relation in Room.

enesgonez
  • 166
  • 6
  • yeah i referred to this but i am not able to get a successful build – Abraham Mathew Nov 07 '18 at 05:36
  • [There is](https://medium.com/@magdamiu/android-room-persistence-library-relations-75bbe02e8522) an example in Java. [There is](https://medium.com/mindorks/room-kotlin-android-architecture-components-71cad5a1bb35) an example in Kotlin. I hope,it will help you. – enesgonez Nov 07 '18 at 05:46
  • followed from this post [https://stackoverflow.com/a/44424148/8601451]. Is there some way without using @TypeConverters? – Abraham Mathew Nov 07 '18 at 05:57