我正在尝试开始使用光滑的.我有一个h2数据库,并使用scala.slick.model.codegen.SourceCodeGenerator生成类.但是,当尝试我尝试按照示例并使用这些类查询我的数据库时,我得到了scala-errors.
生成的代码如下所示:
/** Entity class storing rows of table User * @param id Database column ID PrimaryKey * @param firstname Database column FIRSTNAME * @param lastname Database column LASTNAME */ case class UserRow(id: String, firstname: Option[String], lastname: Option[String]) /** GetResult implicit for fetching UserRow objects using plain SQL queries */ implicit def GetResultUserRow(implicit e0: GR[String], e1: GR[Option[String]]): GR[UserRow] = GR{ prs => import prs._ UserRow.tupled((<<[String], <[String], <[String])) } /** Table description of table USER. Objects of this class serve as prototypes for rows in queries. */ class User(tag: Tag) extends Table[UserRow](tag, "USER") { def * = (id, firstname, lastname) <> (UserRow.tupled, UserRow.unapply) /** Maps whole row to an option. Useful for outer joins. */ def ? = (id.?, firstname, lastname).shaped.<>({r=>import r._; _1.map(_=> UserRow.tupled((_1.get, _2, _3)))}, (_:Any) => throw new Exception("Inserting into ? projection not supported.")) /** Database column ID PrimaryKey */ val id: Column[String] = column[String]("ID", O.PrimaryKey) /** Database column FIRSTNAME */ val firstname: Column[Option[String]] = column[Option[String]]("FIRSTNAME") /** Database column LASTNAME */ val lastname: Column[Option[String]] = column[Option[String]]("LASTNAME") } /** Collection-like TableQuery object for table User */ lazy val User = new TableQuery(tag => new User(tag))
这是我的疑问:
val userResultList = for { u <- User if u.id === "foo" } yield u
这导致:
Error:(137, 29) value === is not a member of db.Tables.profile.simple.Column[String] u <- User if u.id === user.id ^
怎么了?