-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use default ObjectMapper in FormatMappers Configuration for Hibernate ORM's JSONType #32029
Comments
Fair point. From what I can see we would need to register our own In the meantime, an (unsupported) workaround would be to set your own format mapper: quarkus.hibernate-orm.unsupported-properties."hibernate.type.json_format_mapper" = com.acme.MyFormatMapper The implementation would be something like that: public class MyFormatMapper implements org.hibernate.type.format.FormatMapper {
private final org.hibernate.type.format.FormatMapper delegate = new JacksonJsonFormatMapper( Arc.container().instance(ObjectMapper.class).get() );
public <T> T fromString(CharSequence charSequence, JavaType<T> javaType, WrapperOptions wrapperOptions) {
delegate.fromString(charSequence, javaType, wrapperOptions);
}
public <T> String toString(T value, JavaType<T> javaType, WrapperOptions wrapperOptions) {
delegate.toString(value, javaType, wrapperOptions);
}
} |
Thanks for the workaround. It seems to work, I'm running in some other unreleated issues now. |
Sure, I'll get to it... eventually. My backlog is not small :) If anyone wants to contribute this, the right place to start would probably be |
This would be very nice now that quarkus 3.0 is released. |
Agreed.
|
Ah, okay. I'll have a look next week |
I think we need to be a bit careful here as there's a good chance you might need a different mapper than the global one. We had several requests of being able to use different mapper configuration for different use cases. |
Yeah, we would need to perform some checks |
As there is a workaround for the time being, I am going to push this a little further back on my TODO list :) |
I'm adding a +1 on this issue since we're also impacted by this behaviour - and the workaround proposed scream'd "I'll be unstable and not production ready". What's the canonical (and maybe supported) approach to reuse the same OM on the ORM side? |
Hello everyone, any updates on the aforementioned issue? @marko-bekhta |
Hello. See #35113 . It's in the works. |
Hi @yrodiere attempted to implement your workaround #32029 (comment) while awaiting the official fix. The workaround functions seamlessly in JVM mode; however, in native mode, the application encounters an error, and the corresponding error message is as follows: |
Hey @iqnev. That's a warning, not an error? And I think (hope) it's self-explanatory. |
@yrodiere yes, in native mode, the application fails to start, whereas in JVM mode, it starts correctly. I found the hidden error:
It's puzzling why the class cannot be loaded in native mode. |
ahhh Require registration the |
Describe the bug
Hi,
when using
from Hibernate 6 and Jackson the JacksonJsonFormatMapper is used, which uses an ObjectMapper from Jackson.
This ObjectMapper is not configured like the global ObjectMapper and doesn't see the jsr310 dependency on the path.
As result types like LocalDate in the type of the Colume raise an exception.
Expected behavior
It would be nice, if the global ObjectMapper is used or an Method to supply your own
Alternatively use an ObjectMapper that is configured to respect jsr310. This would mitigate most of the problems.
Actual behavior
raises an exception, if SomeObject contains a LocalDate.
How to Reproduce?
Setup a Quarkus project with Hibernate 6.
Write an Entity with
where SomeObject is a pojo with a member of type LocalDate.
Persisten an the entity with data.
Output of
uname -a
orver
windows32 Name 2.6.2 9200 i686-pc Intel unknown MinGW
Output of
java -version
openjdk 11.0.7 2020-04-14 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.7+10) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.7+10, mixed mode)
GraalVM version (if different from Java)
Not used
Quarkus version or git rev
3.0.0.Alpha6
Build tool (ie. output of
mvnw --version
orgradlew --version
)Maven 3.8.4
Additional information
No response
The text was updated successfully, but these errors were encountered: