新戏!类编译器错误:“update not member ...”

时间:2012-08-14 02:09:51

标签: scala squeryl

使用Play!在Scala与Squeryl ORM。我不知道是什么导致了这个问题,但是当我添加一个新的模型来玩!它现在不会编译出一个非常奇怪的错误:

value update is not a member of models.OauthCred

编译器专门指向Squeryl所需的this()的零参数构造函数。

代码如下:

case class OauthCred(
  val id: Long,

  @Column("vendor")
  val vendor: String,

  @Column("user_id")
  val userId: Long,

  @Column("remote_id")
  val remoteId: Option[String],

  @Column("scope")
  var scope: String,

  @Column("access_code")
  var accessCode: Option[String],

  @Column("unauthorized_token")
  var unauthorizedToken: Option[String],

  @Column("authorized_token")
  var authorizedToken: Option[String],

  @Column("refresh_token")
  var refreshToken: Option[String],

  @Column("is_active")
  var isActive: Boolean,

  @Column("is_revoked")
  var isRevoked: Boolean,

  @Column("created")
  val created: Timestamp,

  @Column("modified")
  var modified: Timestamp

) extends KeyedEntity[Long] {

  this() = this(0L, "", 0L, Some(""), "", Some(""), Some(""), Some(""), Some(""), false, false, new Timestamp(), new Timestamp())

}

object OauthCred {

  def get(id:Long) = DB.oauthcred.lookup(id)

  def save(o:OauthCred) = DB.oauthcred.update(o)

  def getByRemoteId(remoteId:String) = { from(DB.oauthcred)( o => where(o.remoteId === Some(remoteId)) select(o) ).headOption }
}

导致这种情况的原因是什么?

1 个答案:

答案 0 :(得分:0)

解决了这个问题,实际上比我想象的要简单得多:

this()实际上需要def this()

希望这有助于未来的用户。