title: Hibernate Criteria + projection with no results
body: <p>I need all distinct people with name &lt;> null:</p>
  
  <pre><code>List&lt;Criterion&gt; conditions = new ArrayList&lt;Criterion&gt;();
  conditions.add(Restrictions.ne("name", null));
  Projection projection = Projections.distinct(Projections.property("name"));
  List&lt;People&gt; result = dao.findByCriteria(conditions, projection);
  </code></pre>
  
  <p>where:</p>
  
  <pre><code>public List&lt;T&gt; findByCriteria(List&lt;Criterion&gt; list, Projection projection) {
  
     try {                
          Criteria criteria = getSession().createCriteria(entityClass);
          if (list != null) {
              for (int i = 0; i &lt; list.size(); i++) {
                  criteria.add(list.get(i));
              }
          }
          if (projection != null) {
              criteria.setProjection(projection);
          }
          List result = criteria.list();
          return result;
     } catch (Exception e) {
          // log
     }
  }
  </code></pre>
  
  <p>and the generated query is:</p>
  
  <pre><code>Hibernate: select distinct this_.name as y0_ from Mrdb this_ where this_.name&lt;&gt;?
  </code></pre>
  
  <p>but I have no results! In fact, using only projection or only a criterion list the query works fine, but using both there is no results. </p>
  
  <p>What am I missing?</p>
  
  <p>Thanks</p>