Scala 为什么slick不能存储选项[String]?

Scala 为什么slick不能存储选项[String]?,scala,playframework-2.0,slick,Scala,Playframework 2.0,Slick,我在playframework 2.2项目中使用了slick 2.0 rc1 我的talbe代码是: case class Resource(id: Option[Long] = None, owner: UserId, types: String) // The static object that does the actual work - note the names of tables and fields in H2 are case sensitive and must be a

我在playframework 2.2项目中使用了slick 2.0 rc1 我的talbe代码是:

case class Resource(id: Option[Long] = None, owner: UserId, types: String)

// The static object that does the actual work - note the names of tables and fields in H2 are case sensitive and must be all caps 
object Resources extends Table[Resource]( "RESOURCE") {
  def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
  def owner = column[UserId]("Owner")
  def types = column[String]("Type")
  def withuser = foreignKey("User_FK", owner, Users)(_.id)

 // Every table needs a * projection with the same type as the table's type parameter
 def * = id.? ~ owner ~ types <> (Resource, Resource.unapply _)
}
但我修改后,还是有错误:

[error] C:\assigment\slick-advanced\app\models\Resource.scala:12: traits or obje
cts may not have parameters
[error] object Resources(tag: Tag) extends TableTable[(Long, UserId, String)](ta
g, "RESOURCE") {
[error]                 ^
[error] one error found
查看施工人员的

new Table(_tableTag: Tag, _tableName: String)
new Table(_tableTag: Tag, _schemaName: Option[String], _tableName: String)
编译器告诉您有这些选择,但没有使用。您只需要一个
字符串
就可以构建名为
资源
表的实例。正如你所见,这不是一个选择。没有双关语的意思

显示您的声明应该更像这样:

class Resources(tag: Tag) extends Table[(Long, UserId, String)](tag, "RESOURCE") {
  ...
}
val Resources = TableQuery[Resources]

我改为类资源(tag:tag)扩展表。。。。正如你所说,但它仍然会遇到错误。请参阅我的更新问题SAN对象无法接受参数。您需要编写一个类并使用TableQuery创建一个值。请查看迁移指南!我忘了说明
object
s不带参数的明显要点。谢谢你收拾残局,克里斯。
new Table(_tableTag: Tag, _tableName: String)
new Table(_tableTag: Tag, _schemaName: Option[String], _tableName: String)
class Resources(tag: Tag) extends Table[(Long, UserId, String)](tag, "RESOURCE") {
  ...
}
val Resources = TableQuery[Resources]