title: java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Long
body: <p>I have this block of code in OrderService.java</p>
  
  <pre><code>    public void deleteOrderByUserId(int userId){
         List&lt;Long&gt; orderIds = orderDAO.getOrderIdByUserId(userId);
         int deleteOrders = orderDAO.deleteOrders(orderIds);
      }
  </code></pre>
  
  <p>This is the code in orderDAO.java</p>
  
  <pre><code>public List getOrderIdByUserId(int userId) {
      StringBuilder queryStr = new StringBuilder("select distinct u.OrderId from ");
      queryStr.append("User u where ");
      queryStr.append("u.UserId in (:key)");
  
      return getHibernateTemplate().getSessionFactory()
              .getCurrentSession().createSQLQuery(queryStr.toString())
              .setParameter("key", userId).list();
  }
  
  
      public int deleteOrders(List&lt;Long&gt; orderIds){
        final String deleteOrder = "delete from Order o where o.OrderId in (:orderIds)";
        final Query hibernateQuery = getHibernateTemplate().getSessionFactory().getCurrentSession().createQuery(deleteOrder);
        hibernateQuery.setParameterList("orderIds", orderIds);
        int count = hibernateQuery.executeUpdate();   
        return count;
       }    
  </code></pre>
  
  <p>I'm getting an <strong>java.lang.ClassCastException: java.math.BigDecimal cannot be cast to java.lang.Long</strong> Exception while executing this step              <strong>int count = hibernateQuery.executeUpdate();</strong></p>
  
  <p>What's wrong with that code and how to get rid of that exception</p>