title: Grails createCriteria and using a Transient field and PagedResultsList
body: <p>Domain Fields:</p>
  
  <pre><code>startDate: Date
  length: Integer
  perpetuity: Boolean
  expiryDate: Transient (startDate + length (in years))
  </code></pre>
  
  <p>Domain methods - These methods are used for filtering on a big filter form for a user to search for the 4 different expiration status'.</p>
  
  <pre><code>Date getExpiryDate() {
      if (this.startDate == null || this.length == null) {
          return null
      }
  
      Timestamp startDate = this.startDate;
      Calendar expirationDate = Calendar.getInstance()
      expirationDate.setTime(startDate)
      expirationDate.add(Calendar.YEAR, this.length)
  
      return expirationDate.getTime()
  }
  
  String getMechExpiredStatus() {
      String isExpiredString = 'Unspecified'
      Date expDate = getExpiryDate()
      if (expDate != null) {
          if (expDate &lt; new Date()) {
              isExpiredString = 'Yes'
          } else {
              isExpiredString =  'No'
          }
  
      } else if (isPerpetual &amp;&amp; startDate != null) {
          isExpiredString =  'Perpetual'
      }
  
      return isExpiredString
  }
  </code></pre>
  
  <p>Building the results list</p>
  
  <pre><code>PagedResultList getMechanisms(offset, max, sortColumn, sortOrder, filters, idsOnly = false) {
      def criteria = Mechanism.createCriteria()
      def results = criteria.list(max: max, offset: offset) {
          if (idsOnly) {
              projections {
                  property('id')
              }
          }
  
          if (filters &amp;&amp; filters.idFilter) {
              eq('id', filters.idFilter);
          }
      ...
      }
  
      if (filters &amp;&amp; filters.expiredFilter != null &amp;&amp; filters.expiredFilter) {
          // Do Work
          // Tried getting results and removed invalid results that do not meet the 
          // expired filter selection
      }
  
  return results
  
  }
  </code></pre>
  
  <p>I cannot seem to find a way to write a createCriteria using the transient field 'expiryDate' nor using the getMechExpiredStatus method.</p>
  
  <p>I've tried getting a list of items with the other filters and then removing the items that aren't valid for the expiration filter separately but the PagedResultList doesn't get updated properly; it just returns a current paged result list. I cannot find much help regarding the PagedResultList object either. Remove and Add returns a boolean for some reason. Apparently I do not understand the object very well.</p>
  
  <p>If I remove the max and offset from the initial criteria list, the query takes a <em>very</em> long time to run.</p>
  
  <p>Any ideas how I can accomplish this?</p>