1 Reply Latest reply on Feb 7, 2007 9:34 AM by christian.bauer

    Upgrading from h3.1 to h3.2 : select count ClassCastExceptio

    craig1980

      Hi everybody.

      I have an application developed under JBoss 4.0.1; in this AS there is hibernate3.1; i have used this version of hibernate for acceding to my DB; i have done a select count by using this sintax:

       protected Query getQueryCount(BaseFilter filter) throws ValidateException, DaoException, IllegalParameterException {
      .
      .
      .
      
      String query = " select count(distinct tbasmusr.id) from TbaSmUsr tbasmusr where " +" tbasmusr.tbuSmUsrOus.size = 0 and tbasmusr.id != 0 ";
      query = query + " and tbasmusr.id != " + idLogged ;
      String nameUser = userFilter.getName();
      
      if( !PropertyValidator.isNullable( nameUser )){
      
       query = query + " and ( tbasmusr.name like '%" + nameUser + "%' or tbasmusr.surname like '%" + nameUser + "%' or tbasmusr.socialName like '%" + nameUser + "%' )";
      }
      
      String userType = userFilter.getUserType();
      
      if( !PropertyValidator.isNullable( userType )){
       query = query + " and tbasmusr.type like '" + userType+"'" ;
      }
      
       return getSession().createQuery( query );
      }
      


      In the old version of Hibernate an Integer was returned by executing this quey; in the hibernate 3.2.0 (present in the AS Jboss 4.0.4) a Long is returned.....this causes a ClassCastException.... is this correct?
      Why this change? Must i recompile all my code by adapting it to this change?

      Thanks to all,
      Angelo.