title: How do I get the values returned with Hibernate?
body: <p>I'm stuck, I run this query with hibernate, but do not know how to get the values that the query returns.</p>
  
  <p><strong>Query:</strong></p>
  
  <pre><code>select idMagistrado, count(*) as numeroDemandas from demandamagistrado group by idMagistrado order by numeroDemandas asc limit 3;
  </code></pre>
  
  <p><strong>DAO:</strong></p>
  
  <pre><code>public Set&lt;Magistrado&gt; get3Magistrado() {
          ConnectionDataBase cdb = new ConnectionDataBase();
          Set&lt;Magistrado&gt; magistrados = null;
  
          try {
              Query createQuery = cdb.getSession().createQuery("select idMagistrado, count(*) as numeroDemandas from demandamagistrado group by idMagistrado order by numeroDemandas asc limit 3");
              // Here, HELP!
              if (magistrados == null) {
                  return null;
              }
          }
          catch (HibernateException he) {
              cdb.catchException(he);
          }
          finally {
              cdb.closeSession();
          }
  
          return magistrados;
      }
  </code></pre>
  
  <p>And the <strong>result</strong> in de <strong>MySQL console</strong>:</p>
  
  <pre><code>mysql&gt; select idMagistrado, count(*) as numeroDemandas from demandamagistrado group by idMagistrado order by numeroDemandas asc limit 3;
  +--------------+----------------+
  | idMagistrado | numeroDemandas |
  +--------------+----------------+
  |            3 |              1 |
  |            2 |              2 |
  |            1 |              3 |
  +--------------+----------------+
  3 rows in set (0.00 sec)
  </code></pre>
  
  <p>The Query object has no method to let me know the values of <strong>idMagistrado</strong> and <strong>numeroDemandas</strong>. I do not know what to do, HELP.</p>