title: Java class cast exception with hibernate criteria query
body: <p>I am getting <code>java.lang.ClassCastException: java.math.BigInteger cannot be cast to java.lang.Long</code> exception while executing <code>int totalCount=criteria.list().size();</code>.
  Please help me to identify the reason and a solution.</p>
  
  <pre><code> public GridPageDet list(DwrParam dwrParam,UserFound user,JobFound job) throws Exception {  
              Query query = getSession().createSQLQuery(
              "select user_id from hs_cust_users where cust_id IN(select cust_id from customers where user_id=:userId)").setParameter("userId", user.getId());
              Collection&lt;Object[]&gt; list = (Collection&lt;Object[]&gt;)query.list();     
  
              Criteria criteria=getSession().createCriteria(Filter.class);
              criteria.createCriteria("filter.typeId", "filterType", Criteria.FULL_JOIN);
              criteria.add(Expression.eq("status", 1)); 
              if(user!=null &amp;&amp; user.getId()!=null){
                  Object statusArr [] = {1};
                  criteria.createCriteria("user", "user", Criteria.FULL_JOIN);                
                  criteria.add(Expression.in("status", statusArr));
  
                  if(user.getAccess().getId().intValue() == Helper.priv.intValue() || 
                          user.getAccess`enter code here`().getId().intValue() == Helper.id.intValue()){
                      criteria.add(Expression.in("user.id", list));
                  }else{
                      criteria.add(Expression.eq("user.id", user.getId()));
                  }
              }
  
              int totalCount=criteria.list().size();
  }
  </code></pre>