如何使用 DAO 从多个表中进行搜索?

How do I search from multiple tables with DAO?

假设我有这样的表:

object Leagues : IntIdTable() {
   val name = varchar("name", 50).uniqueIndex()
}
object Matches: IntIdTable() {
   val game = reference("game", Games)
}
object Users: IntIdTable() {
   val name = varchar("name", 50).uniqueIndex()
}
object Bets: IntIdTable() {
   val match = reference("match", Matches)
   val user = reference("user", Users)
}

道在以下几行:

class Bet(id: EntityID<Int>) : IntEntity(id) {
   companion object : IntEntityClass<Bet>(Bets)

   var match by Bets.match
   var user by Bets.user
}

如何为 Bets class 编写 dao 或查询以便我可以查询 "give me all bets player X has made in league Y"。 Bet.find { (user eq X) and (/* what here to get the leagues table ? */) }

val bets = Bet.wrapRows(
    Bets.innerJoin(Matches).innerJoin(Leagues).select {
        Bets.user eq X.id and (Leagues.name eq "Y"  
    }
).toList()