1
JDK 8、JodaTime 2.9.9およびOrientDBバージョン2.2.26を使用しています。OrientDBオブジェクトAPIのJoda DateTime
OrientDBオブジェクトAPIでDateTimeオブジェクトを使用する方法はありますか?
例クラス:
class Entity {
private DateTime date;
public Entity(DateTime date){
this.date = date
}
public DateTime getDate(){
return date;
}
public void setDate(DateTime newDate){
this.date = newDate;
}
}
OrientDBに登録:
database.getEntityManager().registerEntityClass(Entity)
私はそれを保存しようとした場合:
database.save(new Entity(DateTime.now()))
をそれから私は得る:
com.orientechnologies.orient.core.exception.OSerializationException:
Linked type [class org.joda.time.DateTime:2017–09–12T11:50:25.709–03:00]
cannot be serialized because is not part of registered entities.
私はDateTimeの登録しようとした場合:
にdatabase.getEntityManager().registerEntityClass(DateTime)
をそして私は再び実体を保存しよう:
database.save(new Entity(DateTime.now()))
それが最終クラスであるので、Javassistのが代理ではないので、私が得たことができます。
java.lang.RuntimeException: org.joda.time.DateTime is final
DateTimeではなくlongを格納するようにクラスを変更したくありません。 DateTimeのようなシリアライザとデシリアライザを実装して登録する方法はありますか?同様に、私のエンティティに干渉しないでしょうか?
こんにちは、前に登録されていることが重要であり、あなたはコードを投稿できますか? Thx –
@MichelaBonizzi完了、助けてください!どのバージョンを参照しているのか不明であったので、JDKとJodaのバージョンを追加しました.OrentDBのバージョンはすでにオリジナルのポストになっています。 – VitorCruz
ちょうど興味深い:なぜあなたはJoda Timeを使用していますが、Java8のDate/Time APIを使用していませんか?サイトから:Java SE 8以降では、このプロジェクトを置き換えるJDKの中核部分であるjava.time(JSR-310)に移行するように求められます。 – MystyxMac