ClassCastException due to "javassist" proxy in Hibernate
Issue
- An entity is fetched as part of a
LAZY
association -
When downcasting the entity to the appropriate subclass (e.g. casting
Task
toSubTask
), the following exception is raised:java.lang.ClassCastException: Cannot cast support.hibernate.entity.Task_$$_jvstb10_1 to support.hibernate.entity.SubTask
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7
- 6
- 5
- Red Hat JBoss Fuse 6
- Hibernate
- 4
- 3
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.