Preload two or more level deeper in associations
namnguyentat opened this issue · comments
I created some model classes (I will obviate the imports)
case class Contract(name: String) extends ActiveRecord {
val roomId: Option[Long] = None
lazy val room = belongsTo[Room]
}
case class Room(room_no: String) extends ActiveRecord {
val buildingId: Option[Long] = None
lazy val building = belongsTo[Building]
lazy val contracts = hasMany[Contract]
}
case class Building(name: String) extends ActiveRecord {
lazy val rooms = hasMany[Room]
}
And I want to do something like
Contract.all.includes(_.room => .building)
Like in Rails, we can use preload Contract.all.preload(room: :building).
But I see, with scala-activerecord we only can preload one level like
Contract.all.includes(.room)
So how can I preload tow or more level deeper in associations?
Thank you!