wood burning stoves 2.0*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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