-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class cast exception on hibernate5 module #111
Comments
Unfortunately Hibernate project has made a few incompatible changes to classes this module needs, so this may depend on version of Hibernate you are using. |
I am using Hibernate 5.0.12, tried with 5.1.10 but had the same result. |
@tomaldguz Ok that's odd then. I thought it was 5.2 that was problematic. But maybe a PR to fix things for 5.2 broke 5.0/5.1 instead? For Jackson 3.x I think we will deprecate this module since no one maintains it; it has been nothing but source of problems. |
That would be a shame, I think it is a useful module, I will try to see if it works with 5.2. |
@tomaldguz Agreed. Would definitely like to see new contributors, any help is appreciated. Some of earlier work visible via PRs, may make sense to at-mention people who have worked. |
…s 5.2+ incompatibility problems solved but closer
Ok. So... fundamentally there is a big 5.1->5.2 problem with I made some changes to try to alleviate this, and tried running existing test suite (extra 5-2 compat). Oh joy. |
I am getting this exeption when trying to serialize a a collection of objects with lazy collections as atributes:
com.fasterxml.jackson.databind.JsonMappingException: org.hibernate.internal.SessionImpl cannot be cast to javax.persistence.EntityManager (through reference chain: java.util.ArrayList[0]->com.checkout.model.Category["items"])
The problem is reproducible since 2.8.6 forward, using 2.8.5 I dont have this problem. I am working with spring and hibernate
I am initializing this way:
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter(); ObjectMapper objectMapper = new ObjectMapper(); objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); objectMapper.configure(MapperFeature.DEFAULT_VIEW_INCLUSION, true); Hibernate5Module hibernateModule = new Hibernate5Module(sessionFactory().getObject()); hibernateModule.enable(Hibernate5Module.Feature.FORCE_LAZY_LOADING); objectMapper.registerModule(hibernateModule); jsonConverter.setObjectMapper(objectMapper); return jsonConverter; }
The text was updated successfully, but these errors were encountered: