• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: " );

}
 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic