-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Missing findAndRegisterModules() when initialising the ObjectMapper #70
Comments
Huh. At least going by the documentation, OffsetDateTime should be supported: https://rethinkdb.com/api/java/expr/ I wonder if this could be fixed by a change in https://github.com/rethinkdb/rethinkdb-java/blob/master/build.gradle.kts I'm very unfamiliar with gradle, Jackson, or this driver, so maybe somebody else can chime in. |
Is there any update on that? |
Apparently not. |
Auto-Registering in the current version of Jackson registers the legacy version JSR310Module. Which was depreciated in 2.5. public synchronized static @NotNull ObjectMapper getResultMapper() {
ObjectMapper mapper = resultMapper;
if (mapper == null) {
mapper = new ObjectMapper()
.registerModule(new JavaTimeModule())
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
resultMapper = mapper;
}
return mapper;
}
``` |
With RethinkDB Java Driver 2.4.4, if an OffsetDateTime is being saved, following error occurs:
java.lang.IllegalArgumentException: Java 8 date/time type java.time.OffsetDateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: ch.yourpackage.YourClass["yourField"])
I state that
com.fasterxml.jackson.datatype:jackson-datatype-jsr310
is already in mybuild.gradle
file.To avoid the above issue, as a workaround I need to include this line during RethinkDB initializer:
RethinkDB.setResultMapper(RethinkDB.getResultMapper().findAndRegisterModules());
My advice would be to modify your
getResultMapper()
method in theRethinkDB.java
class as follows:The text was updated successfully, but these errors were encountered: