title: Hibernate - How can I force it programmatically to return Long instead of BigInteger?
body: <p>I have this method in one of the DAOs of my project.<br>
  The underlying RDBMS is MS SQL Server.<br>
  The <code>se_subaccountid</code> is defined as <code>bigint</code> on the DB level.       </p>
  
  <p>Hibernate returns to me <code>List&lt;BigInteger&gt;</code>.<br>
  I don't want to have BigInteger objects but Long objects.<br>
  How I can tell Hibernate to return to me a <code>List&lt;Long&gt;</code>?<br>
  I want to do it programmatically here in this method,<br>
  as I don't want my changes to have global impact.<br>
  Is that possible and how?     </p>
  
  <pre><code>@SuppressWarnings({ "rawtypes", "unchecked" })
  public List&lt;Long&gt; getAllCheckSubAccounts() {
      Object res = getHibernateTemplate().execute(new HibernateCallback() {
          public Object doInHibernate(Session session) throws HibernateException, SQLException {
  
              String sql =
                      "select " + 
                      " " + 
                      "distinct sa.se_subaccountid as cid " + 
                      " " + 
                      "from  " + 
                      "subaccount sa  " + 
                      "inner join account a on sa.accountid = a.accountid " + 
                      "inner join product m on sa.mb_id = m.mb_id  " + 
                      "where " + 
                      "(a.se_id = 2) " + 
                      "and " + 
                      "(sa.se_subaccountid is not null)  " + 
                      "and " + 
                      "(m.mb_status not in (128, 512)) " + 
                      "order by  " + 
                      "sa.se_subaccountid asc ";
  
              SQLQuery query = session.createSQLQuery(sql);
              return query.list();
          }
      });
  
      return ((List&lt;Long&gt;) res);
  }
  </code></pre>