• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve particular object from criteria list, I do not want object array

 
Bhupendra Dubey
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting exception
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; incompatible with com.dto.AppDTO2
at com.action.AppService.main(AppService.java:121)
-----------------------------
code:
List li=criteria.list();
for(Iterator it = li.iterator();it.hasNext();)
{
AppDTO2 appDTO2 =
(AppDTO2) it.next();
System.out.println("ID: " + appDTO2.getCATEGORY());
System.out.println(" Name: " );

}
 
Campbell Ritchie
Sheriff
Pie
Posts: 48938
60
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and the iterator is finding an Object[] type object. You are telling it that is a com.dto.AppDTO2 object, and it isn't. Hence the Exception.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic