File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to retrieve particular object from criteria list, I do not want object array Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to retrieve particular object from criteria list, I do not want object array" Watch "How to retrieve particular object from criteria list, I do not want object array" New topic
Author

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

Bhupendra Dubey
Greenhorn

Joined: May 10, 2011
Posts: 6
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

Joined: Oct 13, 2005
Posts: 36453
    
  15
. . . 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to retrieve particular object from criteria list, I do not want object array
 
Similar Threads
LinkedList Problem
Generics - need help
Dynamically determine Arraylist content type using reflection
Collections copy error
How can i check if an Object[][] is empty