-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Auto-configure Hibernate with a JsonFormatMapper that uses the auto-configured Jackson ObjectMapper #33870
Comments
Thanks for the suggestion. If I have undertood it correctly, you should be able to do this yourself using a @Bean
HibernatePropertiesCustomizer jsonFormatMapperCustomizer(ObjectMapper objectMapper) {
return (properties) -> properties.put(AvailableSettings.JSON_FORMAT_MAPPER,
new JacksonJsonFormatMapper(objectMapper));
} Can you please try this and let us know if it allows you to remove the |
Thank you for getting back, can confirm that this does in fact work fine after removing the annotations. Maybe warrants a separate Kotlin compatibility section in the docs unless it's done by default? |
Thanks for confirming that it works for you. We should consider making this the default behaviour so I've labelled this issue as enhancement. When we come to implement this we should consider the effect that Hibernate using the auto-configured |
I have implemented the following code but it is nor working with springboot 3.0.1 and hibernate 6 @Bean
HibernatePropertiesCustomizer jsonFormatMapperCustomizer(ObjectMapper objectMapper) {
return (properties) -> properties.put(AvailableSettings.JSON_FORMAT_MAPPER,
new JacksonJsonFormatMapper(objectMapper));
} Do you habe another proposal? |
It should work so, without knowing exactly how it isn't working, it's difficult to propose something else. If you'd like some help, please post a question on Stack Overflow that includes a minimal, reproducible example of the problem. |
While looking at #42676 and trying to find some inspiration for a property name, a couple of other things came to mind:
|
We discussed this today and we'd like to wait until the Hibernate feature is not |
After migrating to Spring Boot 3.0.1 and Hibernate 6, I swapped out the Hibernate Types JSON support for the new built in
@JdbcTypeCode(SqlTypes.JSON)
, however my Kotlin data classes failed to deserialize and I had to annotate everything with@JsonCreator
and@JsonProperty
to fix constructors.I feel like this should default to the Jackson instance on the Spring context rather than the Jackson library itself, that is pulled in by Hibernate by default. It should be possible to define a custom mapper factory that can be configured via
hibernate.type.json_format_mapper
and point Hibernate to that instance, see https://github.com/hibernate/hibernate-orm/blob/main/documentation/src/main/asciidoc/userguide/chapters/domain/basic_types.adoc#json-mappingThe text was updated successfully, but these errors were encountered: