spring-projects / spring-projects/spring-boot

Auto-configure Hibernate with a JsonFormatMapper that uses the auto-configured Jackson ObjectMapper

Open
#33,870 24 comments 9 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: blocked status: pending-design-work type: enhancement
Dominant language
Java
Stars
81.5k
Forks
42.7k
Avg merge
2d 4h
Merged PRs (30d)
65

Description

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-mapping

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Spring Boot's Hibernate and Jackson auto-configuration, then read Hibernate's JSON mapping documentation and the hibernate.type.json_format_mapper configuration described in the issue. No repository file or test is named, so locate the relevant auto-configuration and existing integration tests first. Done means Hibernate JSON mapping uses the auto-configured Spring Jackson ObjectMapper, including for Kotlin data-class deserialization without extra constructor annotations.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, kotlin, spring-boot
Domain
backend, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.