-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
TypeBootstrapContext constructor not called in custom types with Hibernate 6 #30924
Comments
@z0mb1ek the documentation you've referenced is from Hibernate and so is the behavior.
Did you test with the same hibernate version? If so can you please share a small sample that reproduces the problem? |
@snicoll Yes, i tested with same hibernate version, just change spring-orm version |
Like I said, please share a small sample we can run ourselves. |
Hello, I think I've a similar issue upgrading from Spring Boot 3.0.8 to 3.0.9. The problem can be "fixed" by overriding spring-orm from 6.0.11 to 6.0.10. After doing some debugging I think that the behaviour change comes from this commit dff7aa4 . For some reason before Spring was using the following constructor to instanciate the bean https://github.com/vladmihalcea/hypersistence-utils/blob/master/hypersistence-utils-hibernate-60/src/main/java/io/hypersistence/utils/hibernate/type/json/JsonBinaryType.java#L56 but now it's using this one https://github.com/vladmihalcea/hypersistence-utils/blob/master/hypersistence-utils-hibernate-60/src/main/java/io/hypersistence/utils/hibernate/type/json/JsonBinaryType.java#L60 . I've no idea if this new behaviour was intended or not. Can you provide some guidance ? Thanks. |
It's really hard to say without looking at an actual sample. There are too many guesses at this point. |
I assume you are both aware that Spring Boot auto-configures a If As for #30683 I believe it's doing the right thing given its contract. To me it looks like this is working as designed but a sample we can run ourselves can make us revisit that. |
@snicoll Thanks. My understanding of that part of Spring is not very good 😅 I'm going to build a minimal sample to make it easier to understand what's going on. |
@snicoll it is not doing right thing because contract is calling constructor which takes the TypeBootstrapContext argument. Or documentation is not correct |
@z0mb1ek as I've asked twice already, please share a small sample that will let us make sure we're seeing the same thing. If the |
Here is failing test into otherwise an empty application:
The set up is quite involved, but here my attempt. What we want is to configure the hypersistence library to use the To force the test to fail, I register JsonComponent that has a non empty constructor, and since Spring make the application context beans available to Jackson, the ObjectMapper in the application will be able to resolve any But, if hypersistence construct it's own ObjectMapper, that one will not be able to create the serializer (non empty constructor) and the test fails. I use the following build.gradle:
Switch between the versions to see it fail. |
Thanks but that doesn't reproduce the problem that you've described initially (also, why paste all that code in text rather than sharing a sample that I can run? The only thing I am forced to do is to copy paste that to a project anyway). The original report is about us not calling |
Hi @snicoll, Apologies, I though I was saving you the trouble of downloading a full project by putting everything in single file 😅. My bad. I'm able to verify that the constructor on |
After investigating Hibernate's implementation there, this special |
@z0mb1ek this is in 6.0.x now. It would be great if you could give the latest 6.0.12 snapshot a try, specifically the latest version of |
@jhoeller Hi, thank you very much for your work, it starts working, BUT we need this:
Very strange property naming, what is this? |
I found this #30545 |
I use spring-orm with hypersistence-utils for additional types. There is class JsonBinaryType that has constructor:
The documentation says that
If a custom Type defines a constructor which takes the TypeBootstrapContext argument, Hibernate will use this instead of the default constructor.
But there is call on default contructor and it is not working.I tested version 6.0.9 - it works, but 6.0.10 and 6.0.11 does not. Is it a bug?
relates to vladmihalcea/hypersistence-utils#644
The text was updated successfully, but these errors were encountered: