aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate Mapping - Object cannot be cast to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate Mapping - Object cannot be cast to" Watch "Hibernate Mapping - Object cannot be cast to" New topic
Author

Hibernate Mapping - Object cannot be cast to

Zoltan Tailor
Greenhorn

Joined: Jun 24, 2012
Posts: 3
Hi Guys,

Here is my Options.hbm.xml, Options.java and ConfigurationLoader.java. The ConfigurationLoader fails because it throws an exception here: option = (Options)lists.get(i);
Its: "java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to database.Options".

What can be the problem?

Thanks,


K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2584
    
    9

Did you try declaring and casting your list as List<Option>?



Then you don't need to cast it again in the for loop.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Zoltan Tailor
Greenhorn

Joined: Jun 24, 2012
Posts: 3
K. Tsang wrote:Did you try declaring and casting your list as List<Option>?



Then you don't need to cast it again in the for loop.


Thanks, unfortunately it does not work this way but a friend of mine suggested to change the HQL just simply to: "FROM options", and that did the magic!

Thanks anyway it solved
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Hibernate Mapping - Object cannot be cast to