title: Can there be an if condition inside the Hibernate Create Criteria?
body: <p>I am using <code>HibernateCriteriaBuilder</code> api to write my Criteria Queries. I want to know if inside <code>Criteria</code> we can have conditional logic, such as an <code>if</code> statement?</p>
  
  <p>For example:</p>
  
  <pre><code> OnemonthList=it.createCriteria().list {   
     if (res_id!='all'){
          eq('graresource',resourceInstance)
     }         
      between('currentdate', fromDate, toDate)         
      projections {       
      trans {
        countDistinct('id')    
      }
      groupProperty('currentdate')
          }                  
      } 
  </code></pre>
  
  <p>Is this valid?</p>