Java Objectify是否支持Joda时间间隔类?
我们使用Objectify5访问Google云数据存储。我们有一个来自Joda时间库的属性类型为Java Objectify是否支持Joda时间间隔类?,java,google-app-engine,jodatime,objectify,google-cloud-datastore,Java,Google App Engine,Jodatime,Objectify,Google Cloud Datastore,我们使用Objectify5访问Google云数据存储。我们有一个来自Joda时间库的属性类型为Interval的实体。当我们试图保存这样一个实体时,会出现下面的错误。Objectify似乎在年表及其子类方面存在问题 com.googlecode.objectify.SaveException: Error saving MyEntity(null): Class 'class org.joda.time.chrono.ISOChronology' is not a registered @Su
Interval
的实体。当我们试图保存这样一个实体时,会出现下面的错误。Objectify似乎在年表
及其子类方面存在问题
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 translators以及我们的实体,如下所示
...
// Joda-Time translators
JodaTimeTranslators.add(ObjectifyService.factory());
// persistent entities
ObjectifyService.register(MyEntity.class);
...
当我们使用DateTime
而不是Interval
时,它可以正常工作。我们错过什么了吗?Objectify是否支持Joda TimeInterval
开箱即用?如果您查看,显然不支持。支持的类型包括:
DateTimeZone
LocalDate
LocalDateTime
DateTime (via ReadableInstant)
也许你可以从源代码中学习并编写你自己的转换器/适配器,例如,看看它的源代码似乎并不那么难。但是您可能必须注册自己的适配器。是的,我检查了源代码,只是想确保没有遗漏任何内容。