lundi 11 mai 2015

Scala reflection to instantiate scala.slick.lifted.TableQuery

I have this base trait

trait MyBase {
  type M
  type T <: Table[M]
  val query: TableQuery[T]
}

Where TableQuery is scala.slick.lifted.TableQuery

My subclasses instantiate TableQuery like so:

type M = Account
type T = AccountsTable
val query = TableQuery[T]

I'd like to instantiate the TableQuery in the base trait, possibly by using a lazy val, i.e.

lazy val query: TableQuery[T] = {
  ...
}

I've been playing around with reflection, but haven't had much luck.





Aucun commentaire:

Enregistrer un commentaire