我使用slick 2.0 rc
我已经定义了字段UserId
:
trait TypedId extends Any {
def value: Long
}
trait HasId[ID <: TypedId] {
_: Table[_] =>
def id: Column[ID]
}
case class UserId(value:Long) extends AnyVal with TypedId
case class User(id: Option[UserId],
email: String,
firstName: String,
lastName: String,
phone:String)
当我使用它时:
class Users(tag: Tag) extends Table[User](tag, "users") with HasId[Option[UserId]] {
def * = (id.?, email, firstName , lastName , phone )<> (User.tupled, User.unapply)
def id= column[Option[UserId]]("ID", O.AutoInc, O.PrimaryKey)
def email = column[String]("EMAIL", O.NotNull)
def firstName = column[String]("FIRST_NAME", O.NotNull)
def lastName = column[String]("LAST_NAME", O.NotNull)
def phone =column[String]("PHONE", O.NotNull)
}
它给我编译错误:
[error] C:\assigment\slick-advanced\app\models\User.scala:27: could not find imp
licit value for parameter tm: scala.slick.ast.TypedType[Option[models.UserId]]
[error] def id= column[Option[UserId]]("ID", O.AutoInc, O.PrimaryKey)