title: Grails "Cannot set readonly property: programId"
body: <p>I got thrown into an existing grails project and one of the issues i'm having is that when saving something a batch, i get the error: <code>Cannot set readonly property: programId</code></p>
  
  <p>Here's my save snippet that causes the error</p>
  
  <pre><code>// Create a batch
  def batch = new Batch()
  batch.name = session.batch_name
  batch.startDate = new Date()
  batch.endDate = new Date()
  batch.programId = 120
  if(batch.save()) {
    ...
  }
  </code></pre>
  
  <p>Here's my batch domain class</p>
  
  <pre><code>class Batch  extends AbstractDomainObject{
      String name
      Date startDate
      Date endDate
      String comments
      StatusType currentStatus
  
      static belongsTo = [program:Program]    
  
      static constraints = {
          name(blank:false,maxSize:100)
          startDate()
          endDate()
          comments (nullable:true, maxSize:DEFAULT_SIZE_OF_COMMENTS)
          currentStatus(nullable:true)
      }
      static transients= ["currentStatus"]
  
      static mapping = {
          id column:'batch_id', generator:'sequence', params:[sequence:'sq_batch']
          currentStatus column:'status_type_id'
          program column:'program_id'
          statuses sort:'statusDate'
          startDate type:'date'
          endDate type:'date'
      }
  
      public String toString(){
          return name
      }
  
  
      public Date createdDate(){
          Date date=null
          if(this?.statuses?.size()&gt;0){
              this?.statuses.each{
                  if(it.status.value==SystemConstants.STATUS_PENDING){
                      date = it.statusDate
                  }
              }
          }
          return date
  
      }
  }
  </code></pre>
  
  <p>Why does it not let me set the <code>programId</code>?</p>