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
The problem here is that EclipseLink apparently expects the addNamedQuery argument to be its Query implementation type, with a hard downcast. Spring creates proxies for Query instances, expecting them to be used for application purposes.
I suppose we should unwrap Query arguments in our EntityManagerFactory proxy before passing it on to the native EntityManagerFactory. That should cover cases like yours for any kind of persistence provider. I'll try that approach for 4.2.5.
FWIW, strictly speaking, EclipseLink should actually do such unwrapping itself: Query has a dedicated unwrap method for that purpose. Before downcasting, EclipseLink should actually call unwrap with the type that it intends to downcast to.
It is also worth noting that the problem only occurs with a shared EntityManager as obtained via @PersistenceContext. Using a regular EntityManager created through EntityManagerFactory.createEntityManager(), Spring is not wrapping any Query objects and therefore no downcasting problem should arise in the first place.
In any case, we'll address this in Spring itself to be on the safe side.
Lukáš Vasek opened SPR-13957 and commented
Hello,
I'm trying to add together spring boot (1.3.2) + eclpselink (2.6.2) + axon framework.
Axon has in it's https://github.com/AxonFramework/AxonFramework/blob/df54dcf98807751a0368ee2e9906879b7f495330/core/src/main/java/org/axonframework/saga/repository/jpa/JpaSagaRepository.java class this construction
which leads to classcast exception. I'm wondering if this is springs or eclipselinks issue.
Thanks
Lukas
Affects: 4.2.4
Reference URL: http://stackoverflow.com/questions/35455351/eclipselink-not-compatible-with-spring
Issue Links:
Referenced from: commits 7fcb277, 4320161
The text was updated successfully, but these errors were encountered: