Reputation:
So I was following: http://slick.typesafe.com/doc/3.0.2/gettingstarted.html and now I'd like to use case classes instead of defining every model as a tuple.
So I have:
case class Character(id: Long, foreName: String, middleNames: String, lastName: String, age: Int)
//class Characters(tag: Tag) extends Table[(Int, String, String, String, Int)](tag, "characters")
class Characters(tag: Tag) extends Table[Characters](tag, "characters")
{
def id = column[Long]("id", O.PrimaryKey, O.AutoInc)
def foreName = column[String]("forename")
def middleNames = column[String]("middlenames")
def lastName = column[String]("lastname")
def age = column[Int]("age")
// def * = (id, foreName, middleNames, lastName, age)
def * = (id, foreName, middleNames, lastName, age) <> (Character.tupled, Character.unapply _)
}
But I get:
Expression of type MappedProjection[Character, (Long, String, String, String, Int)] doesn't conform to expected type ProvenShape[Characters]
But why is that? It's basically the same as: http://de.slideshare.net/rebeccagrenier509/slick-learn2 slide 7. Even if that is Slick 2 only, how can I achieve the same in Slick 3?
Upvotes: 2
Views: 1019
Reputation: 15074
It looks like you want ... extends Table[Character]
, not ... extends Table[Characters]
.
Upvotes: 7