我使用slick 2.0 rc 我已定义字段UserId:
case class UserId(id: Long) extends AnyVal with BaseId
object UserId extends IdCompanion[UserId]
当我使用它时:
class Resources(tag: Tag) extends Table[Resource](tag, "RESOURCE") {
def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
def owner = column[UserId]("Owner")
def types = column[String]("Type")
def withuser = foreignKey("User_FK", owner, Users)(_.id)
它给我编译错误:
[error] C:\assigment\slick-advanced\app\models\Resource.scala:15: could not find
implicit value for parameter tm: scala.slick.ast.TypedType[models.UserId]
[error] def owner = column[UserId]("Owner")
答案 0 :(得分:3)
您不需要UserId对象。您需要一个描述映射的隐式。见http://slick.typesafe.com/doc/2.0.0-RC1/userdefined.html