Scala 游戏框架:Slick不知道如何映射给定的类型

Scala 游戏框架:Slick不知道如何映射给定的类型,scala,playframework,playframework-2.0,slick,play-slick,Scala,Playframework,Playframework 2.0,Slick,Play Slick,我试图在play框架中使用slick,但即使是最简单的例子也很难做到 这是我的密码: case class Account ( id: Int, email: String, password: String, permission: String ) class Accounts(tag: Tag) extends Table[Account](tag, "account") { def id = column[Int]("id") def email = colum

我试图在play框架中使用slick,但即使是最简单的例子也很难做到

这是我的密码:

case class Account (
  id: Int,
  email: String,
  password: String,
  permission: String
)

class Accounts(tag: Tag) extends Table[Account](tag, "account") {
  def id = column[Int]("id")
  def email = column[String]("email")
  def password = column[String]("password")
  def permission = column[String]("permission")

  def * = (id, email, password, permission)
}
编译此文件时,会出现以下错误:

play.PlayExceptions$CompilationException: Compilation error[No matching Shape found.
Slick does not know how to map the given types.
Possible causes: T in Table[T] does not match your * projection. Or you use an unsupported type in a Query (e.g. scala List).
  Required level: scala.slick.lifted.ShapeLevel.Flat
     Source type: (scala.slick.lifted.Column[Int], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String], scala.slick.lifted.Column[String])
   Unpacked type: models.Account
     Packed type: Any
]
有人能告诉我这里有什么问题吗

谢谢

进一步详情:

  • Scala 2.10
  • 光滑2.0.2
  • 玩滑头0.6.0.1
  • 播放框架2.3.1
根据,我认为您的“*”投影方法应该如下所示:

def * = (id, email, password, permission) <> (Account.tupled, Account.unapply)
def*=(id、电子邮件、密码、权限)(Account.tuple、Account.unapply)

我发现了这个问题。我有一个相互冲突的伴星

如果您有一个伴生对象,则需要对*投影使用稍微不同的语法:

def * = (id, email, password, permission) <> ((Account.apply _).tupled, Account.unapply)
def*=(id、电子邮件、密码、权限)((Account.apply 41;).tuple、Account.unapply)

谢谢Pawel。我也试过了,但是我得到了一个错误:value tuple不是对象模型的成员。不确定我是否遗漏了什么。我确实有一些时间戳字段,也许我缺少某种映射?