File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Cannot be cast to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Cannot be cast to" Watch "Cannot be cast to" New topic

Cannot be cast to

Predrag Ristic

Joined: Dec 07, 2009
Posts: 28
In my database there si one to one relationship between person and role.Role has a composite primary key so I'm using RokePk class to map that.When I try to read a certain user from the database this exception occurs:"com.spinnaker.pedja.Role cannot be cast to".Here are the classes:

Any ideas?
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
Maybe make the Role and Person beans also implement Serializable interface. The RolePk bean does.

Error: Keyboard not attached. Press F1 to continue.
Predrag Ristic

Joined: Dec 07, 2009
Posts: 28
Problem solved.Thanks!!!
I agree. Here's the link:
subject: Cannot be cast to
It's not a secret anymore!