Search code examples
scalasqueryl

New Play! class compiler error: "update not member..."


Using Play! in Scala with Squeryl ORM. I have no idea what's causing the problem, but when I added a new model to Play! it now won't compile with a very strange error:

value update is not a member of models.OauthCred

The compiler points specifically to the zero-argument constructor of this() which is required by Squeryl.

The code is below:

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

What could be causing this?


Solution

  • Solved the problem, it was actually a lot simpler than I thought:

    this() actually needed to be def this()

    Hope this helps future users.