Reputation: 8210
We use Objectify 5 to access Google Cloud Datastore. We have an entity with a property of type Interval
from Joda-Time library. When we try to save such an entity, we get the error below. It seems that Objectify has problem with Chronology
and its subclasses.
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)
...
We registered Joda-Time translators in Objectify along with our entities as follows.
...
// Joda-Time translators
JodaTimeTranslators.add(ObjectifyService.factory());
// persistent entities
ObjectifyService.register(MyEntity.class);
...
When we use DateTime
instead of Interval
, it works perfectly OK. Did we miss something? Does Objectify support Joda-Time Interval
out-of-the-box?
Upvotes: 2
Views: 745
Reputation: 44061
If you look at the source code, obviously not. Supported types are:
DateTimeZone
LocalDate
LocalDateTime
DateTime (via ReadableInstant)
Maybe you can learn from the source code and write your own translator/adapter, see for example the source code of LocalDateTranslatorFactory It does not seem to be so difficult. But you have probably to register your own adapter anyway.
Upvotes: 3