You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cannot cast spring created proxy to a different object interface.
e.g.:
Given the bean: @Bean @Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public EntityManager myEntityManager(EntityManagerFactory emf) {
return emf.createEntityManager();
}
If I try to cast it or maybe unwrap the instance, we get a class cast exception: @Autowired
EntityManager em;
Session s = em.unwrap(Session.class) -> ClassCastException
Session s = ((Session) em) -> ClassCastException