-
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
Spring Controller annotated with @JsonView and hibernate4 #73
Comments
The first question usually is whether you can reproduce the behavior without spring, just using Jackson and Hibernate module. My guess is that the problem is that Spring controller is trying to serialize things after Hibernate session is closed; if so, this is not something Jackson has any control over. |
exactly, but Hibernate4 Jackson module trying to handle this (at least for Collections - check PersistentCollectionSerializer). |
Jackson module does not open sessions as far as I recall. It assumes a session exists, during processing. Having said that, I do not use Hibernate nor Spring, so someone else may have to help here. |
Session is opened by hibernate4module, added here: e4b3654 , see for more info: PersistentCollectionSerializer#openTemporarySessionForLoading() Hibernate module opens session for read for each collection, but ignoring simple refs. Please, consider to mark it as a bug if you find inconsistency in the behavior. cast @eoger :) upd. btw, it is really bad approach to open session per property.It is responsibility of another abstraction layer, imho |
I stand corrected. Thank you for pointing this out @bademux. And that does seem wrong to me as well, since it really ought not to be data-binding layer's responsibility. |
Hello,
It isn't a bug, bug nasty behavior.
I configure my MappingJackson2HttpMessageConverter for using ObjectMapper and Hibernate4Module with SessionFactory
Spring along @JsonView-aware Controller has been used
see for more info: "Jackson’s @JsonView is supported directly on @ResponseBody"
I supposed that all Lazy fields will be initiated and serialized, but got "could not initialize proxy - no Session" on
exception goes from
com.fasterxml.jackson.datatype.hibernate4.HibernateProxySerializer#findProxied
Is it expected?
The text was updated successfully, but these errors were encountered: