I'm getting values through query and next i'm trying to iterating values but is throws error
Session session = null;
try{
Query qu=session.createSQLQuery("select plot_no from house_details where type='duplex'");
List<Long> li = qu.list();
System.out.println("---li---"+li.toString());
for (Iterator itr = li.iterator(); itr.hasNext();) {
Object[] obj = (Object[]) itr.next();
String plotNo = (String) obj[0];
if(plotNo=="501" || plotNo== "520" || plotNo== "601"){
System.out.println("---if---");
//code here
}
else{
System.out.println("---else---");
//code here
}
}
}catch(Exception e){
e.printStackTrace();
}finally {
if(session!=null){
session.close();
}
}
output:
---li---[501, 0, 101, 101, 114]
java.lang.ClassCastException: java.math.BigDecimal cannot be cast to [Ljava.lang.Object;
what is wrong in my code. Error getting this lines
Object[] obj = (Object[]) itr.next();
String plotNo = (String) obj[0];