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, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content