在光滑的2.0上,我发现我无法存储用户定义的字段

时间:2013-12-29 16:43:45

标签: scala slick

我使用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")

1 个答案:

答案 0 :(得分:3)

您不需要UserId对象。您需要一个描述映射的隐式。见http://slick.typesafe.com/doc/2.0.0-RC1/userdefined.html