edw*_*ner 2 scala playframework playframework-2.0 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 = column[String]("email")
def password = column[String]("password")
def permission = column[String]("permission")
def * = (id, email, password, permission)
}
Run Code Online (Sandbox Code Playgroud)
当我编译这个时,我收到以下错误:
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
]
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我,如果我在这里有问题吗?
谢谢
更多详情:
edw*_*ner 15
我发现了这个问题.我有一个相互矛盾的伴侣对象
如果您有伴随对象,则需要对*投影使用略有不同的语法:
def * = (id, email, password, permission) <> ((Account.apply _).tupled, Account.unapply)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5296 次 |
| 最近记录: |