This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

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!