内部コレクションのマッピングに問題があります。アイテムは、さまざまなコンテンツ タイプを持つことができます。ここに私の Item クラスがあります:
@Document(collection = "items")
public class Item{
@Id
private ObjectId id;
private List<? super Content> content;
...
}
Content は、この Item のさまざまなコンテンツの基本クラスです。
public class YoutubeVideo implements Content{
private String url;
}
public class Image implements Content{
private String location;
}
...
保存後 (問題なく終了して保存)、コンテンツ コレクションに 1 つの Image クラスと 2 つの YoutubeVideo クラスを持つアイテムで、この JSON を取得します
{ "_id" : { "$oid" : "4e423dcf7f3a0d12265da46c"}
"content" : [
{ "location" : "hdd path"} , { "url" : "url path"} , { "url" : "url path"}
]}
私が期待していたのは、この JSON ではありません。このドキュメントを読み込んで逆シリアル化できない理由も理解できます。
java.lang.RuntimeException: Can not map ? super trngl.mongo.domain.content.Content
この種のオブジェクトをどのようにマッピングしますか? オブジェクトを手動でシリアライズおよびデシリアライズしたくありません。出来ますか?
関心のあるコンバーター クラスが見つかりました: mapping-explicit-converters