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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Cannot be cast to java.io.Serializable" Watch "Cannot be cast to java.io.Serializable" New topic
Author

Cannot be cast to java.io.Serializable

Predrag Ristic
Greenhorn

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 java.io.Serializable".Here are the classes:

Person.java:


Role.java


RolePk.java:


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
Greenhorn

Joined: Dec 07, 2009
Posts: 28
Problem solved.Thanks!!!
 
Consider Paul's rocket mass heater.
 
subject: Cannot be cast to java.io.Serializable
 
Similar Threads
One to many mapping problem
@SqlResultSetMapping
Can't use Optimistic Locking
issue with Xdocler Ant Task
Help? Compliation Errors