title: difference between criteria.add and criteria.equals
body: <p>what is difference between <strong>criteria.add</strong> and <strong>criteria.equals</strong> in hiberante criteria?</p>
  
  <p>just example:</p>
  
  <p>returns 25 records</p>
  
  <pre><code>criteria.equals(Restrictions.eq("templateType", TemplateType.DEFAULT_TEMPLATE));
  </code></pre>
  
  <p>returns 2 records:</p>
  
  <pre><code>criteria.add(Restrictions.eq("templateType", TemplateType.DEFAULT_TEMPLATE)); 
  </code></pre>
  
  <p>when I do <code>hibernate.show_sql</code>, then output is</p>
  
  <ul>
  <li>for <code>criteria.equals</code>, no syntax generated </li>
  <li>for <code>criteria.add</code> , this_.template_type=?</li>
  </ul>
  
  <p>Note: Using Hibernate 3. </p>
  
  <p><strong>Edit:</strong></p>
  
  <pre><code>try{
  List&lt;Form&gt; forms=Collections.emptyList();
  Criteria normCriteria=session.createCriteria(NormMaster.class);
  normCriteria.add(Restrictions.eq("id",normId));
  normCriteria.setProjection(Projections.property("libraryId"));
  List&lt;Long&gt; libNormIds=normCriteria.list();
  
  if(libNormIds!=null &amp;&amp; libNormIds.size()&gt;0)
  {
      Criteria criteria=session.createCriteria(Form.class);
      criteria.add(Restrictions.in("normId", libNormIds));
      criteria.equals(Restrictions.eq("templateType", TemplateType.DEFAULT_TEMPLATE));
      //criteria.add(Restrictions.eq("templateType", TemplateType.DEFAULT_TEMPLATE));
      criteria.setFetchMode("formControlMaps", FetchMode.JOIN);
      criteria.setFetchMode("formControlMaps.data", FetchMode.JOIN);
      criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
      forms=criteria.list();
  }
  return forms;
  }
   catch (Exception e) {
       e.printStackTrace();
  }
  </code></pre>