Skip to content
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

Problem with JsonType serialization with spring-data 3.2 and hibernate 6.3 #704

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jongyoonlee
Copy link

I ran into this issue while migrating my app from spring boot 2 to spring boot 3. This PR contains a test case to illustrate the problem.

There are some Entity objects with Java collection type members that map to json column in a table. They are annotated with JsonType. I noticed the tests for persisting those entities using named query were failing after migrating to spring boot 3. It looks like the code path in hibernate for handling named query is completely different from code path for persisting. It ends up doing Java serialization instead of the custom serialization for JsonType.

…nate:6.3 in named query handling JsonType serialization
@vladmihalcea
Copy link
Owner

The HashMultimap is not supported by JsonType, so how would JsonType know how to instantiate it.

I don't see how that worked in any version of this library. So, how do you think it can work?

@jongyoonlee
Copy link
Author

If you look at the test case, it writes the entity object twice, once using repository.persist(), and second time using named query. With hibernate 6.3, repository.persist() code path still works. I suppose it goes through objectMapper. With hibernate 5 it worked for both code paths.

If you are saying it's not supposed to work, I don't know what to tell you except that it did work before. :)

@vladmihalcea
Copy link
Owner

Try to debug it and see why it was working on Hibernate 5 and fails on Hibernate 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants