Open davide1995 opened 1 year ago
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. and replaced by JavaTimeModule
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: