2

Here is my POJO in kotlin:

data class Pass(var uuid: String,
                var activationRestrictions:List<ActivationRestriction>)


data class ActivationRestriction(var uuid: String,
                                 var activationRestrictionExceptions:List<ActivationRestrictionException>)


data class ActivationRestrictionException(var uuid: String)

How can I represent this nested relation with Room? Here is one of the solution, but it does not contain a nested relation. I am specifically looking for solving a nested relationship with Room.

Omkar Amberkar
  • 1,952
  • 4
  • 16
  • 21

1 Answers1

0

You can use @Relation annotation for POJO classes.

A convenience annotation which can be used in a Pojo to automatically fetch relation entities. When the Pojo is returned from a query, all of its relations are also fetched by Room.

Here is the documentation.

Also, this answer has more details: Android Persistence room: "Cannot figure out how to read this field from a cursor"

gsb
  • 5,520
  • 8
  • 49
  • 76