Skip to content

ClassCastException in JpaHibernateConnectionProvider with spring 5.3 #1034

Description

@7erg

Exception:
java.lang.ClassCastException: class com.sun.proxy.$Proxy113 cannot be cast to class org.hibernate.internal.SessionImpl (com.sun.proxy.$Proxy113 and org.hibernate.internal.SessionImpl are in unnamed module of loader 'app')
at org.javers.spring.jpa.JpaHibernateConnectionProvider.getConnection(JpaHibernateConnectionProvider.java:22)

Here
(SessionImpl)entityManager.unwrap(Session.class);

entityManager.unwrap(Session.class) now returns Proxy instead of SessionImpl instance, because of changes in HibernateJpaVendorAdapter: entityManagerInterface changed from HibernateEntityManager (deprecated) to Session.

Probable fix: (SessionImpl)entityManager.unwrap(SessionImpl.class);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions