Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot be cast to java.io.Serializable

For me, the problem was a bug in Hibernate when using non-pk relations: https://hibernate.atlassian.net/browse/HHH-7668

As a workaround, I implemented Serializable and the exception is gone


You should implement Serializable interface.


My experience was this. I had a chain of parent/child relationships working. Then, I was forced to refactor. During the process, I failed to update all my annotations correctly. That is when I started receiving the cast to Serializable error. I implemented Serializable, and this exposed the real problems. Once everything was working, I was able to remove Serializable.

So, in answer to your question, the real problem may be in your setup, and Hibernate is trying to work around the issues by serializing certain entities. Try temporarily implementing Serializable to expose the issues, and then removing it.


The only other solution is to implement Externalizable.