[英]spring-data-mongodb converters on embedded documents doesn't work
我需要閱讀包含bean( ChildDocument )列表的文檔 ( ParentDocument )。 和這些bean, 我只需要轉換一個特定的字段 ( content )即可更改值。 它僅用於讀取mongoDb並加載bean,而不用於將修改存儲在mongodb中。
例如:
@Document(collection = "parent")
class ParentDocument {
@Id
String id;
List<ChildDocument> children;
}
@Document
class ChildDocument {
@Id
String id;
// Modify the content reading in the database before storing the result in the java bean
String content;
}
我嘗試在ChildDocument上使用轉換器,但是它不起作用,因為轉換器未用於ChildDocument之類的嵌入式文檔(我認為嗎?)。
有人可以幫助我,並有一個干凈的解決方案嗎?
謝謝
我的解決方案是:
好吧,您所需要做的只是轉換觸發子項轉換的父級文檔。
再見...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.