新玩法!类编译器错误:"update not member..."



Using Play! in Scala with Squeryl ORM.我不知道是什么导致了问题,但是当我向Play添加了一个新模型时!它现在不会编译一个非常奇怪的错误:

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 }
}

可能是什么原因造成的?

解决了

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

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

希望这对未来的用户有所帮助。

相关内容

最新更新