Closed
Description
Rodolfo Labsch opened SPR-15010 and commented
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
Affects: 4.2.8
Issue Links:
- Support for Hibernate ORM 5.2 [SPR-14327] #18899 Support for Hibernate ORM 5.2