问题
I use slick 2.0 rc I have defined field UserId:
case class UserId(id: Long) extends AnyVal with BaseId
object UserId extends IdCompanion[UserId]
when I use it:
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)
it give me compile error as:
[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:
You don't need an object UserId. You need an implicit that describes the mapping. See http://slick.typesafe.com/doc/2.0.0-RC1/userdefined.html
来源:https://stackoverflow.com/questions/20827533/on-slick-2-0-i-find-i-can-not-store-user-defined-field