4

There is a class in Slick ORM called TableQuery. Its companion object has apply method:

def apply[E <: AbstractTable[_]]: TableQuery[E] =
macro TableQueryMacroImpl.apply[E]

I have class Users extends Table that extends AbstractTable so I can write this:

class Users(tag: Tag) extends Table[User](tag, "users") {..some code..}
val query = TableQuery[Users]

I want to generalize work with database so I created class Dao

class Dao[A, B <: AbstractTable[A]] {
   private val query = TableQuery[B]
}

Here compiler says: "class type required but B found". When I change B <: AbstractTable[A] to B: ClassTag it doesn't run too.

So what generic type do I have to use to send it to TableQuery?

  • This post may help [http://stackoverflow.com/questions/32522128/slick-3-reusable-generic-repository/32524071#32524071](http://stackoverflow.com/questions/32522128/slick-3-reusable-generic-repository/32524071#32524071). – Allen Chou Sep 18 '15 at 01:31
  • Thank you. This thread helped me. – Sergey Shpadyrev Sep 18 '15 at 06:14

0 Answers0