Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Slick 2.0.2错误:value==不是Tables.profile.simple.Column[String]的成员_Scala_Slick - Fatal编程技术网

Scala Slick 2.0.2错误:value==不是Tables.profile.simple.Column[String]的成员

Scala Slick 2.0.2错误:value==不是Tables.profile.simple.Column[String]的成员,scala,slick,Scala,Slick,我正在尝试开始使用slick。我有一个h2数据库,并使用scala.slick.model.codegen.SourceCodeGenerator生成了类。但是,当我尝试以下示例并使用这些类查询我的数据库时,我得到了scala错误 生成的代码如下所示: /** Entity class storing rows of table User * @param id Database column ID PrimaryKey * @param firstname Database

我正在尝试开始使用slick。我有一个h2数据库,并使用scala.slick.model.codegen.SourceCodeGenerator生成了类。但是,当我尝试以下示例并使用这些类查询我的数据库时,我得到了scala错误

生成的代码如下所示:

 /** 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))
/**存储用户表行的实体类
*@param id数据库列id PrimaryKey
*@param firstname数据库列firstname
*@param lastname数据库列lastname*/
case类UserRow(id:String,firstname:Option[String],lastname:Option[String])
/**GetResult隐式用于使用普通SQL查询获取UserRow对象*/
隐式def GetResultUserRow(隐式e0:GR[String],e1:GR[Option[String]]):GR[UserRow]=GR{
prs=>导入prs_

tuple((对于
slick 2.x
,只需导入
XXXDriver.simple.\u
,编译器会很高兴的


对于
slick 3.x
,它的
XXXDriver.api.\u

您是否导入了
隐式
?它可以在导入
XXXDriver时导入。很简单。
就是这样。导入丢失了。非常感谢。
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
                            ^