Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-16433

[GSS](7.2.z) HHH-13281: java.lang.ClassCastException: org.hibernate.internal.SessionImpl cannot be cast to org.hibernate.ejb.HibernateEntityManager

    XMLWordPrintable

Details

    • +
    • Workaround Exists
    • Hide

      In Hibernate 5.3, the entity manager can be unwrapped directly to Session and this is appropriate moving forward as the additional layer of indirection provided by HibernateEntityManager offers no additional benefit.

      org.hibernate.Session session = entityManager.unwrap(org.hibernate.Session.class);
      
      Show
      In Hibernate 5.3, the entity manager can be unwrapped directly to Session and this is appropriate moving forward as the additional layer of indirection provided by HibernateEntityManager offers no additional benefit. org.hibernate.Session session = entityManager.unwrap(org.hibernate.Session.class);

    Description

      The code below worked in Hibernate 5.1 and earlier releases

      org.hibernate.ejb.HibernateEntityManager em = entityManager.unwrap(org.hibernate.ejb.HibernateEntityManager.class);
      

      In Hibernate 5.3, the same code fails with:

      java.lang.ClassCastException: org.hibernate.internal.SessionImpl cannot be cast to org.hibernate.ejb.HibernateEntityManager
             at support.hibernate.entity.TestHibernate.test(TestHibernate.java:56)
      

      Attachments

        Issue Links

          Activity

            Public project attachment banner

              context keys: [headless, issue, helper, isAsynchronousRequest, project, action, user]
              current Project key: JBEAP

              People

                gbadner@redhat.com Gail Badner (Inactive)
                rhn-support-sfikes Stephen Fikes (Inactive)
                Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: