ClassCastException due to "javassist" proxy in Hibernate

Solution Verified - Updated -

Issue

  • An entity is fetched as part of a LAZY association
  • When downcasting the entity to the appropriate subclass (e.g. casting Task to SubTask), 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 of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.