我正在尝试在播放框架中使用光滑,但即使是最简单的示例也要挣扎。
这是我的代码:
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
]
有人能告诉我这里有什么不对吗?
由于
进一步详情:
答案 0 :(得分:15)
我找到了这个问题。我有一个相互矛盾的伴侣对象
如果您有伴侣对象,则需要对*投影使用略有不同的语法:
def * = (id, email, password, permission) <> ((Account.apply _).tupled, Account.unapply)
答案 1 :(得分:3)
根据http://slick.typesafe.com/doc/2.0.2/schemas.html,我认为您的“*”投影方法应如下所示:
def * = (id, email, password, permission) <> (Account.tupled, Account.unapply)