title: How to resolve exception java.lang.ClassCastException: java.math.BigDecimal cannot be cast to [Ljava.lang.Object; in java
body: <p>In my code <code>query</code> is working fine but at the time of iteration it throws this error.</p>
  
  <p>My code here:</p>
  
  <pre><code>Session session = null;
  try{
      Query qu=session.createSQLQuery("select plot_no from house_details where type='duplex'");
      List&lt;Long&gt; li =  qu.list();
      System.out.println("---li---"+li.toString());
      for (Iterator itr = li.iterator(); itr.hasNext();) {
          String plotNo = itr.next().toString();
  
          if(plotNo.equals("501") || plotNo.equals("520") || plotNo.equals("601"){
              System.out.println("---if---");
              //code here
          }
          else{
              System.out.println("---else---");
              Query qu1 = session.createSQLQuery("select distinct name,houseno from house_details");
              List li1 =  qu1.list();
              for (Iterator itr1 = li.iterator(); itr1.hasNext();) {
                  Object[] obj = (Object[]) itr1.next();
                  String houseName = (String) obj[0];
                  String houseNo = (String) obj[1];
                  System.out.println("---houseName---&gt;"+houseName);
              }
      }
  }catch(Exception e){
     e.printStackTrace();
  
  }finally {
     if(session!=null){
      session.close();
     }
  }
  </code></pre>
  
  <p><strong>output:</strong></p>
  
  <pre><code>---li---[501, 0, 101, 101, 114]
  ---else---
  java.lang.ClassCastException: java.math.BigDecimal cannot be cast to [Ljava.lang.Object;
  </code></pre>
  
  <p>it shows error in <code>Object[] obj = (Object[]) itr1.next();</code> line.</p>
  
  <p>What's wrong in my code?</p>