title: How to properly set value of an object in Scala?
body: <p>I've got a Scala def that takes parameters from an HTTP POST and parses the data. I'm pulling a "job" object from the database (the query was successful as verified in the debugger, and parameters are just as they need to be) and I'm trying to update that job object with the new parameters. However, trying to assign values are proving useless since the job object retains all original values. </p>
  
  <p>All database objects are from Squeryl. Code below:</p>
  
  <p><strong>Edit:</strong> added class below and Job object to help give context in this Play! app</p>
  
  <pre><code>object Job {
    def updateFromParams(params:Params) = {
      val job = Job.get( params.get("job_id").toLong ).get
  
      val comments =  params.get("comments")
      val startTime = parseDateTime(params.get("start_time") + " " + params.get("date"))
      val endTime = parseDateTime(params.get("end_time") + " " + params.get("date"))
      val clientId = params.get("client_id").toLong
            val client = Client.get(clientId).get
      val name = params.get("job_name")
      val startAddressType = params.get("start_address_type")
      var startLocationId:Option[Long] = None
      val (startAddress, startCity, startProvince) = startAddressType match {
        case "client" =&gt; getClientAddress(clientId)
        case "custom" =&gt; (params.get("start_custom_address"),
                  params.get("start_custom_city"),
                  params.get("start_custom_province"))
        case id =&gt; {
        startLocationId = Some(id.toLong)
          getLocationAddress(startLocationId.get)
        }
      }
  
      job.comments -&gt;  comments
      job.startTime -&gt; startTime
      job.endTime -&gt; endTime
      job.clientId -&gt; clientId
      job.name -&gt; name
      job.startAddressType -&gt; startAddressType
      job.startAddress -&gt; startAddress
      job.startCity -&gt; startCity
      job.startProvince -&gt; startProvince
  
  
      Job.update(job)
    }
  }
  </code></pre>
  
  <p>I'm stumped because if I try <code>job.name -&gt; name</code> nothing happens and if I try <code>job.name = name</code> then I get a Scala <code>reassignment to val</code> error. I get the same error when trying <code>var name</code> instead of <code>val name</code>.</p>
  
  <p>It's obviously a syntax issue on my part, what's the proper way to handle this? Thanks!</p>
  
  <p><strong>More Info:</strong> if this helps, here's the Job class used in our Play! app:</p>
  
  <pre><code>class Job(
    val id: Long,
  
    @Column("name")
    val name: String,
  
    @Column("end_time")
    val endTime: Timestamp,
  
    @Column("start_time")
    val startTime: Timestamp,
  
    @Column("client_id")
    val clientId: Long,
  
    @Column("start_address_type")
    var startAddressType:String,
  
    @Column("start_address")
    var startAddress: String,
    /* LOTS MORE LIKE THIS */
  ) extends KeyedEntity[Long] {
  }
  </code></pre>