Objectify 是否支持 Joda 时间间隔 class?

Does Objectify support Joda-Time Interval class?

我们使用 Objectify 5 访问 Google Cloud Datastore。我们有一个来自 Joda-Time 库的 属性 类型 Interval 的实体。当我们尝试保存这样的实体时,会出现以下错误。似乎 Objectify 对 Chronology 及其子类有问题。

com.googlecode.objectify.SaveException: Error saving MyEntity(null): Class 'class org.joda.time.chrono.ISOChronology' is not a registered @Subclass
    at com.googlecode.objectify.impl.EntityMetadata.save(EntityMetadata.java:95)
    at com.googlecode.objectify.impl.WriteEngine.save(WriteEngine.java:75)
    at com.googlecode.objectify.impl.SaverImpl.entities(SaverImpl.java:60)
    at com.googlecode.objectify.impl.SaverImpl.entity(SaverImpl.java:35)
...

我们在 Objectify 中注册了 Joda-Time 转换器以及我们的实体,如下所示。

...

// Joda-Time translators
JodaTimeTranslators.add(ObjectifyService.factory());

// persistent entities
ObjectifyService.register(MyEntity.class);

...

当我们使用 DateTime 而不是 Interval 时,它工作得很好。我们错过了什么吗? Objectify 是否支持开箱即用的 Joda-Time Interval

如果你看source code,显然不是。支持的类型有:

DateTimeZone
LocalDate
LocalDateTime
DateTime (via ReadableInstant)

或许你可以借鉴源码,自己写translator/adapter,比如看LocalDateTranslatorFactory的源码,好像也没那么难。但无论如何您可能必须注册自己的适配器。